Language: C#
Query for Files in Version Control
using Microsoft.TeamFoundation.VersionControl.Client; // query the version control repository for items matching a file specification // set the folder for the root of your search String rootFolder = "$/MyProject"; // construct the set of item specifications you want to search for ItemSpec[] itemSpecs = new ItemSpec[] { new ItemSpec(String.Format("{0}/*.sln", rootFolder), RecursionType.Full), }; // make the call to retrieve the matching items ItemSet[] itemSets = versionControl.GetItems(itemSpecs, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.File, GetItemsOptions.Unsorted); foreach (ItemSet itemSet in itemSets) { // cast the Items property to an IEnumerable so we can run a linq query on it IEnumerable<Item> items = (IEnumerable<Item>)itemSet.Items; // let's sort the results by check-in date var sortedItems = from item in items orderby item.CheckinDate descending select item; foreach (Item item in sortedItems) { Debug.WriteLine(item.ServerItem); } }
Tags:
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

