简体   繁体   English

使用ReSharper开放API的当前文件的完整路径名

[英]Full path name of the current file using the ReSharper open API

I am new to ReSharper and was trying to write some simple plugins. 我是ReSharper的新手,正在尝试编写一些简单的插件。 I wanted to try to get full path of the file I am currently using. 我想尝试获取当前正在使用的文件的完整路径。

Something like "C:\\Project1\\Firstfile.cs". 类似于“ C:\\ Project1 \\ Firstfile.cs”。 If I am using "FirstFile.cs" in Visual Studio. 如果我在Visual Studio中使用“ FirstFile.cs”。

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. 我需要使用一些API来获取路径的信息会有所帮助。

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. 现在, ProjFile.Location.ToString()应该返回您projectFile的完整路径。

Good Luck!! 祝好运!! Shaun 肖恩

如果可以等待Visual Studio 11,则可以使用属性CallerFilePath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM