开发者

How to get the path of the Currently opened file from eclipse IDE?

开发者 https://www.devze.com 2023-03-22 08:31 出处:网络
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.

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


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消