Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
 I am trying to create a workspace and map a folder to my local drive, I want a single file to be mapped to my drive (I am not able to get single or full folder as well in my local drive)

Info: TFS 2015 .Net Framework 4.6.1 Visual studio 2017

I put 2 copies of code but both are not working. No idea why? Searching for solution since couple of days please help.

Here is my Code

Version 1:

   <pre lang="c#">sFromFullPath = "$/ProjectName/Main/Sub.Folder1/Sub.Folder2/Sub.Folder3/FileToBeDownaded.cs";
            //string sServerFileName = "FileToBeDownaded.cs";
   Workspace workspace = null;
   string localPath = "C:\\ProjectNameLocal\\" + sFromFullPath.Substring(2, (sFromFullPath.LastIndexOf('/') - 1)).Replace('/', '\\');
   if (Directory.Exists(localPath) == false) Directory.CreateDirectory(localPath);
   workspace= versionControlServer.GetWorkspace("TFSWORKSPACE", versionControlServer.AuthenticatedUser.ToString());

   if(workspace==null) workspace = versionControlServer.CreateWorkspace("TFSWORKSPACE");
   workspace.Map(sFromFullPath, localPath);
   workspace.Get();<pre>

Version 2:

C#
workspace.CreateMapping(new WorkingFolder(sFromFullPath, localPath));
workspace.Get();

If posssible want to have a single file only which user has selected, but I am not able to get the file or the whole folder as well in my local drive.

//when I check this varible it is false means my mapping is not happening at all
C#
var newbol = workspace.IsLocalPathMapped(localPath);

Am I missing something?

What I have tried:

1) I tried using local and server folder directly in workspace.map(serverpath.localpath) 2) I tried using workspace.createmapping(new workingFolder(serverpat,localpath))

do i need to include the path without file? Please help me. I am searching for the answer since long. Stackoverflow is also not able to answer.
Posted
Updated 25-Oct-22 21:24pm

1 solution

Hello, did you found a solution for you? I have the same challenge...
 
Share this answer
 
Comments
Richard Deeming 26-Oct-22 5:11am    
"Me too" is not a solution to anyone's question.

If you want to ask for more information, click the "Have a Question or Comment?" button under the solution and post a comment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900