Sometimes you need to operate to a Tfs Version Control System with API starting from a local folder. There are a lot of API to work with workspaces, but the main problem is that you need to pass through a VersionControlServer object, and to obtain such an object you need to know the address of the Tfs server the workspace is mapped to?
The exercise is the following one :) â€“ Write a snippet of code, based on TFS API that, given a local path, retrieve ChangesetId that is currently mapped on the workspace.
Now that you have a workspace info, getting the info you need is really simple, first of all you can know the Team Project Collection address thanks to the ServerUri property of the WorkspaceInfo object, moreover the WorkspaceInfo object can create a valid Workspace object with a simple call to GetWorkspace method, passing a valid TfsTeamProjectCollection object. Here is the code.
Now you have both the VersionControlServer object and the Workspace object, and you can use the QueryHistory method to know the information you need.
And you have the ChangesetId currently mapped to the local folder.