Normally, this code is used for converting from File
to IFile
:
IWorkspace workspace= ResourcesPlugin.getWorkspace(); IPath location= Path.fromOSString(file.getAbsolutePath()); IFile ifile= workspace.getRoot().getFileForLocation(location);
But this only works for java files within the project. How can I get the IFile
when File
file is not in the workspace (not in the project)?
I am converting using following code. file = ifile. getFullPath(). toFile();
Click on your open project in either the Project Explorer or Package Explorer windows. Then File/Copy (or Ctrl-C), then immediately File/Paste (or Ctrl-V). Your'll get a wizard to save the project under a new name. oh my word.
IResource
and its child IFile
were originally meant to be used only for resources located in the workspace. See the Javadoc for IResource.
However, since Eclipse 3.3 there is support for external files as well, see this Eclipse Wiki page.
I needed this for using the Binding Resolutions from the Eclipse AST framework. But apparently, this is not possible - for anyone who need it, check this site:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206391
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With