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

322 Views Asked by At

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:\Project1\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.

2

There are 2 best solutions below

1
On BEST ANSWER

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

0
On

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