来自C#的TFS 文件签出

来自C#的TFS 文件签出,第1张

概述除了将它用于源代码控制之外,我对TFS没有太多经验.我正在开发一个C#应用程序,它需要修改由TFS控制的文件.从我的C#应用​​程序中,如何查看通过TFS控制的文件? 谢谢 – 兰迪 您可以使用PendEdit使文件可写,对其进行更改,然后将其添加到挂起的更改中,最后将其签入. 下面是一些代码,其中创建文件夹结构然后签入(非常类似于您将需要的). private static void Creat 除了将它用于源代码控制之外,我对TFS没有太多经验.我正在开发一个C#应用程序,它需要修改由TFS控制的文件.从我的C#应用​​程序中,如何查看通过TFS控制的文件?

谢谢 – 兰迪

解决方法 您可以使用PendEdit使文件可写,对其进行更改,然后将其添加到挂起的更改中,最后将其签入.

下面是一些代码,其中创建文件夹结构然后签入(非常类似于您将需要的).

private static voID CreateNodes(ItemCollection nodes){    using (var tfs = TeamFoundationServerFactory.GetServer("http://tfsserver:8080"))    {        var versionControlServer = tfs.GetService(typeof (VersionControlServer)) as VersionControlServer;        versionControlServer.NonFatalError += OnNonFatalError;        // Create a new workspace for the currently authenticated user.                     var workspace = versionControlServer.CreateWorkspace("Temporary Workspace",versionControlServer.AuthenticatedUser);        try        {            // Check if a mapPing already exists.            var workingFolder = new WorkingFolder("$/testagile",@"c:\tempFolder");            // Create the mapPing (if it exists already,it just overIDes it,that is fine).            workspace.CreateMapPing(workingFolder);            // Go through the folder structure defined and create it locally,then check in the changes.            CreateFolderStructure(workspace,nodes,workingFolder.Localitem);            // Check in the changes made.            workspace.CheckIn(workspace.GetPendingChanges(),"This is my comment");        }        catch (Exception ex)        {            MessageBox.Show(ex.Message);        }        finally        {            // Cleanup the workspace.            workspace.Delete();            // Remove the temp folder used.            Directory.Delete("tempFolder",true);        }    }}private static voID CreateFolderStructure(Workspace workspace,ItemCollection nodes,string initialPath){    foreach (RadTreeVIEwItem node in nodes)    {        var newFolderPath = initialPath + @"\" + node.header;        Directory.CreateDirectory(newFolderPath);        workspace.PendAdd(newFolderPath);        if (node.HasItems)        {            CreateFolderStructure(workspace,node.Items,newFolderPath);        }    }}
总结

以上是内存溢出为你收集整理的来自C#的TFS /文件签出全部内容,希望文章能够帮你解决来自C#的TFS /文件签出所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1249628.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存