listing all contents of a folder in tfs

Sidd picture Sidd · Jul 13, 2010 · Viewed 7.8k times · Source

Given a particular path of folder in tfs, I need to recursively find all files and folders within the folder for a given changeset. In other words, i need to get the transitive closure of a path in tfs for a given changeset. The problem I'm facing in doing so is listing the contents of a particular folder within tfs.. How would this be possible in C# ?

Answer

James Manning picture James Manning · Jul 14, 2010

I'm assuming you want 'folder contents as of changeset X' and not 'folder contents that were part of changeset X'

GetItems is the right call to use, just pass in a version spec for the changeset you're interested in.

http://msdn.microsoft.com/en-US/library/bb138911.aspx

so, assuming you already have a reference to the VersionControlServer instance:

var myFolderAtChangeset17 = versionControlServer.GetItems("$/MyFolder", new ChangesetVersionSpec(17), RecursionType.Full);

If I misunderstood and you happen to want to 'folder contents that were part of changeset X', there's a few different ways of doing it, but getting the changeset with GetChangeset and just filtering the Changes is pretty simple.