Reputation: 118
Having file name as string. Ex: Sample.c. How to get IFile from this?
Upvotes: 2
Views: 1241
Reputation: 111142
If you have a path which is the full path in the file system you can use:
IPath path = new Path("C:\\Users\\runtime-EclipseApplication\\Rule_Validate\\Sample_Test.h");
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile file = root.getFileForLocation(path);
Note: The result may be null
if the location is not in the workspace.
There are other APIs if you have a path relative to the workspace or a project/folder in the workspace.
Upvotes: 4