Click here to Skip to main content
15,892,222 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I'm new to development and am coding a VB.NET program and I cannot figure out how to either:
a) Copy file(s) from TFS to the hard drive
b) Read the contents of file(s) in TFS

The google searches I've attempted have proven unsuccessful.

Thus far I'm using the following .dll's from the VS2008 SDK:

Microsoft.TeamFoundation.Client.dll
Microsoft.TeamFoundation.VersionControl.Client.dll
Microsoft.TeamFoundation.VersionControl.Common.dll
Posted

Createa a VersionControlServer instance..

Then call the GetItem method to obtain the instance of the file you want to download, then call its Download method.

E.g.

C#
TeamFoundationServer tfsServer = new TeamFoundationServer(tfsUri, credentials);
VersionControlServer vcServer = (VersionControlServer)tfsServer.GetService(typeof(VersionControlServer));
if (vcServer == null)
    throw new ApplicationException("Invalid vcServer");

Item i = vcServer.GetItem(@"$/Path/To/MyFile.File");
i.DownloadFile(@"C:\MyFile.File");


I just noticed you're doing this in VB.Net, should be easy to convert from C#.
 
Share this answer
 
v7
Comments
Nishant Kumar Choudhary 21-Jan-14 4:29am    
Hi,
In a similar way instead of copying to local folder, I need to copy files\folders from one TFS server to another TFS server using C# code.

Kindly don't suggest any tool for this.
Here few clarification first, If your project is already connect (added) to Team foundation server or not.

If yes you need to follow these steps

1. Open the View menu and choose the team explorer
2. then connect to server, by clicking the "connect to server".
3. then choose the project
4. Open the files in the project and right click on any file, it will give you different option to choose this file.

i) Get Latest version
ii) get the Specific version options


If this answer is not correct, Give the explanation more.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900