3

I am developing a plugin. I want to know the currently opened file's path name programmatically. It would be of great help anyone could help.

Thanks Partha

user844066
  • 83
  • 3

1 Answers1

2

You can use IWorkbenchPage.getActiveEditor or getEditors(), then you can ask the editors for their IEditorInput. If the editor is operating on an IFile (and there is no guarantee that it is), then you can cast IEditorInput to IFileEditorInput to get access to the file via IFileEditorInput.getFile().

Once you get IFile you can get path eaisly

References http://www.eclipse.org/forums/index.php/mv/tree/12808/

Vinay Lodha
  • 2,185
  • 20
  • 29