I'm using TFS SDK. I mapped a project with TFS on Visual Studio. And in my code, I check the server path and local path is mapped already? Their values are true, but workspace.DeleteMapping() method throws when I try to delete the mapped path.
It says "Doesn't find any mapping in [local path]" . But workspace.IsLocalPathMapped(LocalFolder) method returns true value?
WorkingFolder workfolder = new WorkingFolder(ServerFolder, LocalFolder);
workspace = workspaces[0];
if (workspace.IsServerPathMapped(ServerFolder) && workspace.IsLocalPathMapped(LocalFolder))
{
workspace.DeleteMapping(workfolder);
}
IsServerPathMapped and IsLocalPathMapped tell you if a given server path or local path is underneath (or equivalent to) one of the workspace mappings. For instance, let's say you had a recursive mapping set up like this:
C:\dev\project -> $/TeamProject/Main
If you ran IsServerPathMapped on the item "$/TeamProject/Main/Solution/foo.cs" it would return true because that file lies underneath one of your recursive mappings. The IsServerPathMapped function is asking "If I do a GetLatest will this file be in my workspace" and here the answer is yes.
If you can explain a little bit more about what your trying to accomplish with this code, I may be able to point you at different APIs to use.