Skip to content

Instantly share code, notes, and snippets.

@richorama
Created January 7, 2014 12:03
Show Gist options
  • Save richorama/8298356 to your computer and use it in GitHub Desktop.
Save richorama/8298356 to your computer and use it in GitHub Desktop.
Download files from Visual Studio Online
var netCred = new NetworkCredential("username", "password");
var basicCred = new BasicAuthCredential(netCred);
var tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
var tfs = new TfsTeamProjectCollection(new Uri("https://XXX.visualstudio.com/DefaultCollection/"), tfsCred);
tfs.Authenticate();
var vcs = tfs.GetService<VersionControlServer>();
var items = vcs.GetItems(@"$\", RecursionType.Full);
foreach (var item in items.Items)
{
Console.WriteLine(item.ServerItem);
if (item.ItemType == ItemType.File)
{
item.DownloadFile(item.ServerItem.Split('/').Last());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment