Workspace.get未将服务器文件获取到本地文件夹。映射也没有发生 [英] Workspace.get is not getting the server file to local folder. Mapping is also not happening
问题描述
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>
版本2:
Version 2:
workspace.CreateMapping(new WorkingFolder(sFromFullPath, localPath));
workspace.Get();
如果posssible想要只有一个文件,只有哪个用户选择了,但我无法获取文件或整个文件夹也在我的本地驱动器中。
//当我检查这个变量时它是假的意味着我的映射完全没有发生
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
var newbol = workspace.IsLocalPathMapped(localPath);
我是遗失了什么?
我尝试了什么:
1)我尝试直接在workspace.map(serverpath.localpath)中使用本地和服务器文件夹2)我尝试使用workspace.createmapping(new workingFolder(serverpat,localpath))
do我需要包含没有文件的路径?请帮我。我很久以来一直在寻找答案。 Stackoverflow也无法回答。
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.
推荐答案
/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))。替换('/','\\');
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>
/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>
版本2:
Version 2:
workspace.CreateMapping(new WorkingFolder(sFromFullPath, localPath));
workspace.Get();
如果posssible想要只有一个文件,只有哪个用户选择了,但我不能在我的本地驱动器中获取文件或整个文件夹。
//当我检查这个变量时它是假的意味着我的映射根本没有发生
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
var newbol = workspace.IsLocalPathMapped(localPath);
我错过了什么吗?
我尝试了什么:
1)我尝试直接在workspace.map(serverpath.localpath)中使用本地和服务器文件夹2)我尝试使用workspace.createmapping(new workingFolder(serverpat,localpath))
我需要包含没有文件的路径吗?请帮我。我很久以来一直在寻找答案。 Stackoverflow也无法回答。
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.
这篇关于Workspace.get未将服务器文件获取到本地文件夹。映射也没有发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!