How do I pick up the selected source file in a visual studio extension?

164 Views Asked by At

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.

1

There are 1 best solutions below

2
On

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.