views:

28

answers:

1

I have the same problem as the guy in this post: http://stackoverflow.com/questions/299619/get-the-absolute-path-of-the-currently-edited-file-in-eclipse

but I dont understand how to do it. In the post they say that I should use IResource.getRawLocation() but how to I get the IResource from the current file that I am viewing?

IFile file2 = (IFile)workBench.getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput().getAdapter(IFile.class);

IPath path = file2.getRawLocation().makeAbsolute();
String ss = path.toString();

System.out.println(ss);

But this will still not give me the right path to the linked file, I get something like: /path/to/plugin/path/to/relative/path/to/file

A: 

An IFile is-an IResource. You don't need to get one from another. Just call file2.getRawLocation(). If that's not working it's not because it's not an IResource.

Is the file in a jar/zip/any archive file? If so, it looks like that could be the correct absolute path.

Mark Peters
i think its working now:)
hidayat