0

I am writing have a visual studio extension.

What I want to do is run a menu option (ok done this) which picks up the file I have selected using the source control explorer and works with it.

Any Ideas how I can get this file? I really need the file itself and the TFS path $/....

This is not the selected file in "Solution Explorer".

Thanks in anticipation.

Kevin Badger
  • 91
  • 1
  • 1
  • 3

1 Answers1

0

You can use the code like this:

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;

See Browse one folder up in Sorce Control Explorer for a complete sample.

Sergey Vlasov
  • 26,641
  • 3
  • 64
  • 66
  • That looks just right but I don't get a reference to TeamFoundation I am using Visual Studio Community 2015. What do I need to install otherwise to get that? – Kevin Badger Mar 10 '17 at 12:48
  • @KevinBadger See http://stackoverflow.com/questions/32438852/where-is-microsoft-visualstudio-teamfoundation-versioncontrol-dll-in-visual-stud – Sergey Vlasov Mar 10 '17 at 18:12