Getting the Source Control path of a file - VS SDK

By Anoop Madhusudanan

Vote on HN
If you are developing VS Packages, here is something you might need to have a look into.

We are obtaining the source control bindings, and local bindings of the window's document, and finds the source control path from that.
 
public string GetSCPath(EnvDTE.Window window) 
{
 EnvDTE.Document doc=window.Document;

 if (window.DTE.SourceControl.IsItemUnderSCC
               (window.Document.FullName))
            {
                SourceControlBindings bindings = 
                   (window.DTE.SourceControl as 
                     EnvDTE80.SourceControl2).GetBindings 
                                       (window.Project.FullName);

                string scPath=bindings.ServerBinding +
                             doc.FullName.ToLower().Replace
                            (bindings.LocalBinding.ToLower(),"").Replace
                                            ("\\","/");
                return scPath;
            }

     return null;
 
}

No comments:

Post a Comment

Please keep your comments clean.

© 2012. All Rights Reserved. Amazedsaint.com