Reputation: 279
I am creating a tool which initially needs a user to connect to TFS. It is my first time to know about it and I would have to code the connection without actually testing it because my machine is not in domain. I would just like to know the basics of it, specifically checking out files. I've searched that to check out files, it needs to have a workspace.
I am using c# language, by the way.
Upvotes: 0
Views: 3566
Reputation: 16685
You can take the workspace from the file you want to check out, as follows:
string localPath = @"c:\ws\myfile.cs";
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsServer));
// Get a reference to Version Control.
_versionControl = tfs.GetService<VersionControlServer>();
_workspace = _versionControl.TryGetWorkspace(localPath);
if (_workspace == null)
{
throw new Exception("Workspace is not mapped");
}
Upvotes: 1
Reputation: 1377
Check out this blog post that provides example code for a C# console app that demonstrates programmatically connecting and checking out files with Team Foundation Server 2010 and above.
Upvotes: 2