以编程方式将文件从本地文件夹复制到TFS [英] Copying files from local folder to TFS programatically
问题描述
我正在构建一个应用程序,该应用程序应具有从本地文件夹复制文件的功能,并在单击按钮时将其保存在TFS中。为了达到这个目的,我做了很多谷歌搜索,我找不到一个合适的解决方案。所以,我的问题是,是否可以使用C#以编程方式将新文件添加到TFS?如果是,那么我们可以添加到TFS的文件类型是否有任何限制?如果我们可以通过编程方式将新文件从本地文件夹添加到TFS,有人可以提供相同的参考代码吗?提前致谢
我的尝试:
我试过了创建工作区并使用PendAdd方法将文件添加到工作区。工作区正在创建,但我在TFS中找不到工作区。下面是我用来创建工作区的代码
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(< tfs uri>));
$ />
fs.EnsureAuthenticated();
VersionControlServer vcs = tfs.GetService< versioncontrolserver>();
工作区ws = vcs.CreateWorkspace ( DCSCode);
//我:temp是需要的文件位置
//移动到TFS
int r = ws.PendAdd(@I:temp);
I am building an app, which should have a functionality to copy files from a local folder and save it in TFS on a button click. I did lot of googling to get a solution for this purpose , I couldn't find an apt one. So, my question is, is it possible to add new files to TFS programatically using C#?. If yes, then is there any restriction on the file types we can add to TFS?. if we can add new files from a local folder to TFS programmatically, can someone please provide me a reference code for the same?. Thanks in advance
What I have tried:
I have tried creating a workspace and add file to the workspace using PendAdd method. The workspace is getting created, but I couldn't find the workspace in the TFS. Below is the code I have used to create the workspace
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");
推荐答案
TFS 2010及更新版本的Team Foundation版本控制客户端API示例 - Buck Hodges [ ^ ]
这篇关于以编程方式将文件从本地文件夹复制到TFS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!