How can I get an IResource from an IFile or from an absolute path?
I tried with:
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
resource = root.findMember(file.getAbsolutePath());
But I get a null
value.
IFile
扩展了IResource
,换句话说, IFile
是IResource
。
IFile
extends IResource
so if you have an IFile
you have an IResource
.
findMember
treats the path it is given as relative to the container (the workspace root in this case). So you can't use it to find a file given an absolute file path - you must use the findFilesForLocation
APIs for that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.