C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Visual Studio »

Retrieving Files from TFS programatically


Posted Date: 27 Dec 2007    Resource Type: Code Snippets    Category: Visual Studio
Author: Ganapathy SubramaniamMember Level: Gold    
Rating: 1 out of 5Points: 10



I have created an application for my own purpose, that will retrieve all the files from TFS programatically. Code for files retrieval have been given here.


using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Common;
using Microsoft.TeamFoundation.VersionControl.Client;
....
TeamFoundationServer tfs = new TeamFoundationServer("http://TFSServer:Port/", new System.Net.NetworkCredential("sUserName", "sPassword"));
tfs.EnsureAuthenticated();

Workspace workspace = null;
try
{
// Connect to TFS Source Control
VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

// Create a Workspace
string repository = txtWorkspace;

// location to check out files to:
string workspacePath = @"" + "Folder";

workspace = vcs.CreateWorkspace("TestWorkSpace", vcs.AuthenticatedUser);
WorkingFolder folder = new WorkingFolder(repository, workspacePath);

// Get Files
workspace.CreateMapping(folder);
workspace.Get();
}
catch(Exception ex)
{
//Exception has to be handled here
}
finally
{
// clean up the workspace for subsequent passes.
if (workspace != null)
workspace.Delete();
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Asynchronous Execution of a method using Delegates and Call-back method
Previous Resource: Database Connection (Connection String)
Return to Discussion Resource Index
Post New Resource
Category: Visual Studio


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use