TFS从TFS获取文件的延迟 [英] TFS delays in getting files from TFS

查看:116
本文介绍了TFS从TFS获取文件的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码从TFS检索文件.该方法执行没有错误,但是当我尝试访问下载的文件时,出现错误消息,指出找不到文件.
我认为在"DownloadFile"和实际将文件放到我的本地文件之间会有一个延迟.
有什么建议吗?

I''m using the following code to retrieve a file from TFS. The method executes without error but when I try to access the downloaded file, I get an error saying the file cannot be found.
I think there is a delay between "DownloadFile" and actually putting the file on my local.
Any suggestions?

public static void GetFileFromTFS(string filePath, string filename)
  {       
   try
   {
    string fileStr = null;
    _server.Authenticate();
    WorkItemStore store = new WorkItemStore(_server);
    Item file = null;
    fileStr = filePath  + filename;
    file = _versionControl.GetItem(fileStr);
    file.DownloadFile(filePath + Path.GetFileName(file.ServerItem)); 
    }
     catch (Exception ex)
      { Trace.WriteLine("Unknown Error.  Message returned: \n" +     
                         ex.Message, "Unknown Error");
      }
         
}

推荐答案

如果您自己寻找文件,该文件在吗?如果您不知道在哪里看,那么问题就很明显了.您将需要创建一个工作区.

http://msdn.microsoft.com/en-us/library/ms181384.aspx [ ^ ]

为了使代码正常工作,它也需要存在于工作空间中.顺便说一下...在组合路径和文件名时,您可能需要考虑使用Path.Combine(filePath + Path.GetFileName(file.ServerItem));

您还可以同时指定serverpath和localpath:
http://msdn. microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.versioncontrolserver.downloadfile%28v=vs.80%29.aspx [
Is the file there if you look for for it yourself? If you wouldn''t know where to look, then the problem is obvious. You would need to create a workspace.

http://msdn.microsoft.com/en-us/library/ms181384.aspx[^]

For your code to work it would also need to exist in the workspace. By the way... when combining a path and a filename you might want to consider using Path.Combine(filePath + Path.GetFileName(file.ServerItem));

You could also specify both serverpath and localpath:
http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.versioncontrolserver.downloadfile%28v=vs.80%29.aspx[^]

Good luck!


这篇关于TFS从TFS获取文件的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆