Workspace.Get is not getting the server file to local folder. Mapping is also not happening RRS feed

  • Question

  • 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: Net Framework 4.6.1 Visual studio 2017

    I will put 2 copies of code but both are not working. No idea why? 


    Version 1

       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);

    Version 2

    workspace.CreateMapping(new WorkingFolder(sFromFullPath, localPath));

    If possible 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
    var newbol = workspace.IsLocalPathMapped(localPath);

    What is that I am missing.?

    Friday, December 7, 2018 5:56 AM

All replies

  • Hi GKhedekar,

    Thank you for posting here.

    Since your question is more related to TFS, you could post a new thread in StackOverFlow.


    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework, including Managed Extensibility Framework (MEF), Charting Controls, CardSpace, Windows Identity Foundation (WIF), Point of Sale (POS), Transactions.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 11, 2018 7:54 AM