user2545071
user2545071

Reputation: 1410

How to download previous version on file at TFS 2013?

I want to download previous version of source code at TFS 2013.

I can get latest version:

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

But how to get previous version?

Upvotes: 0

Views: 241

Answers (1)

Giulio Vian
Giulio Vian

Reputation: 8353

Easy.

With VersionControlServer.GetItem you get the metadata for the file/folder version you are interested in; then call DownloadFile on it do get the content.

There are many overloads so you can choose the best for you scenario.

You can see an example at Get latest version of file at a specific date/time

Upvotes: 2

Related Questions