[英]IFile to IResource
How can I get an IResource from an IFile or from an absolute path? 如何从IFile或绝对路径获取IResource?
I tried with: 我尝试了:
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
resource = root.findMember(file.getAbsolutePath());
But I get a null
value. 但是我得到一个
null
值。
IFile
扩展了IResource
,换句话说, IFile
是IResource
。
IFile
extends IResource
so if you have an IFile
you have an IResource
. IFile
扩展了IResource
因此,如果您具有IFile
您具有IResource
。
findMember
treats the path it is given as relative to the container (the workspace root in this case). findMember
将给定的路径视为相对于容器(在这种情况下为工作空间根目录)的路径。 So you can't use it to find a file given an absolute file path - you must use the findFilesForLocation
APIs for that. 因此,您不能使用它来查找具有绝对文件路径的文件-您必须
findFilesForLocation
使用findFilesForLocation
API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.