开发者

Full path name of the current file using the ReSharper open API

开发者 https://www.devze.com 2023-02-25 11:57 出处:网络
I am new to ReSharper and was trying to write some simple plugins. I wanted to try to get full path of the file I am currently using.

I am new to ReSharper and was trying to write some simple plugins. I wanted to try to get full path of the file I am currently using.

Something like "C:\Proje开发者_如何学编程ct1\Firstfile.cs". If I am using "FirstFile.cs" in Visual Studio.

I was planning to show the full path as tooltip. Information of the few APIs I need to use to get the path would be helpful.


You can try the following:

public ICSharpFile CSFile = _process.ProjectFile.GetPsiFile(CSharpLanguageService.CSHARP) as ICSharpFile;
public IProjectFile ProjFile = CSFile.GetProjectFile();

Now, ProjFile.Location.ToString() should return you the complete path of your projectFile.

Good Luck!! Shaun


If you can wait for Visual Studio 11 you can use attribute CallerFilePath.

0

精彩评论

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