How to init VersionControlServer class?

2019-06-01 10:44发布

问题:

I want to download file from TFS 2013. I found the VersionControlServer class: msdn

But how to initialize it?

 VersionControlServer vs;
 vs.DownloadFile(repositoryPath,localPath); // vs not initialized!

Thank you!

回答1:

String repositoryPath = "$/MyColl1/Folder1/Folder2/TargetFile.txt";
    String localPathStored = Environment.CurrentDirectory + "/" + "TargetFile.txt";
    String uriSite = "http://tfs-server:8080/tfs/../../vN.0/....asmx";
    TfsTeamProjectCollection teamProjectCollection =TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(uriSite));

    VersionControlServer versionControlServer = teamProjectCollection.GetService<VersionControlServer>();
    versionControlServer.DownloadFile(repositoryPath, localPathStored);