string serverPath = "$/CM/DF_CM_1.1/WD_PR/SRC/Digiwin.ERP.VERSION";
int changeItemNumber = 0;
TeamFoundationServer ownerTFS = new TeamFoundationServer("http://tdserver:8080/", new NetworkCredential("user", "password")); ownerTFS.Authenticate();
VersionControlServer ownerVCS = (VersionControlServer)ownerTFS.GetService(typeof(VersionControlServer));
Workspace ws = ownerVCS.GetWorkspace("CM_WS", ownerVCS.AuthenticatedUser);
changeItemNumber = ws.SetLock(serverPath, LockLevel.CheckOut, RecursionType.Full);
用上述代码锁定TFS上的文件使用的时间突然变得很长,大概需要10分钟。但直接TFS上锁定某个解决方案却比较快。用ws.SetLock方法锁定文件耗费时间的长短是否与TFS上的某个设置有关系