TFS获取文件在百分比中运行进度

时间:2016-08-29 11:52:41

标签: c# winforms tfs

我使用以下代码从TFS下载分支: -

        TeamFoundationServer tfs = new TeamFoundationServer("URL", System.Net.CredentialCache.DefaultCredentials);
        // tfs server url including the  Collection Name --  CollectionName as the existing name of the collection from the tfs server 
        tfs.EnsureAuthenticated();

        VersionControlServer sourceControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

        Workspace[] workspaces = sourceControl.QueryWorkspaces(workspaceName, sourceControl.AuthenticatedUser, Workstation.Current.Name);
        if (workspaces.Length > 0)
        {
            sourceControl.DeleteWorkspace(workspaceName, sourceControl.AuthenticatedUser);
        }
        Workspace workspace = sourceControl.CreateWorkspace(workspaceName, sourceControl.AuthenticatedUser, "Temporary Workspace");
        try
        {
            workspace.Map(projectPath, workingDirectory);
            GetRequest request = new GetRequest(new ItemSpec(projectPath, RecursionType.Full), VersionSpec.Latest);
            GetStatus status = workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite); // this line gets the status of request

        }
        finally
        {
            if (workspace != null)
            {
                workspace.Delete();

            }
        }

我想在ProgressBar中显示状态但不能这样做。我甚至使用BackGroundWorker工具。所以请帮忙。

1 个答案:

答案 0 :(得分:0)

不幸的是,没有这样的TFS API可以实现你所需要的。

作为解决方法,您可以尝试在Windows PowerShell脚本或Windows批处理(cmd)文件中使用进度指示器。