在eclipse API中,如何从位于项目或工作区外的文件中获取IFile

时间:2022-11-05 17:56:41

I want to create IFile interface to open file that locate outside project or workspace.

我想创建IFile接口来打开位于项目或工作区外部的文件。

How to get IFile interface?

如何获得IFile接口?

Regards, Simon

1 个解决方案

#1


http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_on_a_file_outside_the_workspace%3F

You can create a linked resource:

您可以创建链接资源:

IPath location = new Path(name);
IFile file = project.getFile(location.lastSegment());
file.createLink(location, IResource.NONE, null);

Or, if you can use the EFS interface (since Eclipse 3.3), you can use that instead of IFile.

或者,如果您可以使用EFS接口(从Eclipse 3.3开始),您可以使用它而不是IFile。

#1


http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_on_a_file_outside_the_workspace%3F

You can create a linked resource:

您可以创建链接资源:

IPath location = new Path(name);
IFile file = project.getFile(location.lastSegment());
file.createLink(location, IResource.NONE, null);

Or, if you can use the EFS interface (since Eclipse 3.3), you can use that instead of IFile.

或者,如果您可以使用EFS接口(从Eclipse 3.3开始),您可以使用它而不是IFile。