如何初始化VersionControlServer类?

时间:2014-11-07 07:37:10

标签: c# version-control tfs repository tfs2013

我想从TFS 2013下载文件。我找到VersionControlServer课程:msdn

但是如何初始化呢?

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

谢谢!

1 个答案:

答案 0 :(得分:3)

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);