2017-03-08 74 views
0

我正在寫視覺工作室擴展。如何在Visual Studio擴展中選取所選源文件?

我想要做的是運行一個菜單選項(確定完成這個),它選取使用源代碼管理器選擇的文件並使用它。

任何想法如何我可以得到這個文件? 我真的需要文件本身和TFS路徑$/....

這不是「解決方案資源管理器」中選定的文件。

感謝您的期待。

回答

0

您可以使用這樣的代碼:

Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt versionControl = 
       DTE.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") 
      as Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt; 
string file = versionControl.Explorer.CurrentFolderItem.SourceServerPath; 

一個完整的樣本見Browse one folder up in Sorce Control Explorer

+0

這看起來是正確的,但我沒有得到一個參考TeamFoundation 我正在使用Visual Studio社區2015. 我需要什麼來安裝,否則爲了得到它? –

+0

@KevinBadger請參閱http://stackoverflow.com/questions/32438852/where-is-microsoft-visualstudio-teamfoundation-versioncontrol-dll-in-visual-stud –