Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C代码以编程方式向TFS添加文件_C#_Tfs - Fatal编程技术网

C# 使用C代码以编程方式向TFS添加文件

C# 使用C代码以编程方式向TFS添加文件,c#,tfs,C#,Tfs,我正在开发一个应用程序,它可以从指定的路径获取一些文件,并通过单击按钮移动到TFS。我的第一个问题是,是否可以使用C?以编程方式向TFS添加新文件?。如果是,那么我们可以添加到TFS的文件类型是否有任何限制?。下面是我尝试在TFS中创建工作区的代码 TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(<tfs uri>)); tfs.EnsureAuthenticated(); VersionCon

我正在开发一个应用程序,它可以从指定的路径获取一些文件,并通过单击按钮移动到TFS。我的第一个问题是,是否可以使用C?以编程方式向TFS添加新文件?。如果是,那么我们可以添加到TFS的文件类型是否有任何限制?。下面是我尝试在TFS中创建工作区的代码

TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(<tfs uri>));

tfs.EnsureAuthenticated();
VersionControlServer vcs = tfs.GetService<VersionControlServer>();
Workspace ws = vcs.CreateWorkspace("DCSCode");    

//"I:temp" is the location of files which needs to be 
  //moved to TFS
int r = ws.PendAdd(@"I:temp");
您需要创建一个新的或获取现有的工作区->挂起更改->签入这些更改->解决冲突(如果有)

供您参考的相关代码段:

//Get the current workspace
WS = versionControl.GetWorkspace(workspaceName, versionControl.AuthorizedUser);     

//Mapping TFS Server and code generated
WS.Map(tfsServerFolderPath,localWorkingPath);

//Add all files just created to pending change
int NumberOfChange = WS.PendAdd(localWorkingPath,true);
//Get the list of pending changes
PendingChange[] pendings = WS.GetPendingChanges(tfsServerFolderPath,RecursionType.Full);

//Auto check in code to Server
WS.CheckIn(pendings,"CodeSmith Generator - Auto check-in code.");

您也可以在这里找到一个示例:

这里没有问题陈述。我们应该怎么做?阅读TFS API文档,或者以编程的方式在添加文件TFS上显示结果,这些单词可以按任何顺序排列。首先,我们不是你们的军队。第二,请提供一个你尝试过的例子。我们为什么要做你的工作?请展示您已经尝试过的内容,以及您遇到的具体问题。您好,抱歉提供的信息不足。我正在创建一个应用程序,在该应用程序中,只要单击按钮,特定文件夹中的文件就必须移动到TFS。这些文件是DCS代码文件DCS是一个数据转换工具。我已经尝试了下面的代码,我创建了一个工作区,并尝试将一个文件添加到此工作区。但是当我在TFS中进行验证时,我看不到正在创建工作区。谢谢您的解决方案。我会试试这个。@ShruthiGururaj你解决问题了吗?有更新吗?这对你有用,你可以,这对阅读这篇文章的其他社区成员是有益的。