I'm working with TFS API by C# and I have some trouble:
If I have the sever path, for instance @"$/MyCompanyName/Services/MyFiles"
and I want to get appropriate mapped folder like @"C:\\MyCompanyName\\Services\\MyFiles"
by using C#? For instance: I have source control path as constant that given from somewere, and I need to figure out the appropriate mapped path on local file system (if exists one).
I found the answer by myself:
1). First, needs to find the Workspace instance:
var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(@"$/MyFolder1/MyFolder2/MyFolder3");
if (workspaceInfo != null) //is already exists
{
var server = new TfsTeamProjectCollection(workspaceInfo.ServerUri);
workspace = workspaceInfo.GetWorkspace(server);
}
2). Second step is calculation of mapped folder:
string workspaceFolderFullPath = workspace?.GetLocalItemForServerItem((@"$/MyFolder1/MyFolder2/MyFolder3");
After you have connected to the team project, you can manage your workspaces from the Team Explorer home page or from Source Control Explorer.
After you choose Add or Edit you can modify working folders in a new or an existing workspace.
More information, check: https://www.visualstudio.com/en-us/docs/tfvc/create-work-workspaces
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.