/// <summary> /// 获取TFS服务器该目录的最新版本 /// </summary> /// <param name="serverPath"></param> /// <param name="recursionType"></param> public void GetLatesByServerPath(string serverPath, JoeyRecursionType recursionType = JoeyRecursionType.Full) { ItemSet its = version.GetItems(serverPath, (RecursionType)(int)recursionType); if (!dic.ContainsKey(serverPath)) { dic.Add(serverPath, its); foreach (var item in its.Items) { string localItem = GetLocalPathByServerPath(item.ServerItem); if (item.ItemType == ItemType.Folder) { if (!Directory.Exists(localItem))//判断目录是否存在 { Directory.CreateDirectory(localItem); } } else if (item.ItemType == ItemType.File) { item.DownloadFile(localItem);//下载最新版本 } } } }
/// <summary> /// 获取文件所在目录的最新版本 /// </summary> /// <param name="localPath"></param> /// <param name="recursionType">JoeyRecursionType</param> public void GetLatest(string localPath, JoeyRecursionType recursionType = JoeyRecursionType.Full) { //获取文件目录 string serverPath = Path.GetDirectoryName(GetServerPathByLocalPath(localPath)); GetLatesByServerPath(serverPath, recursionType); }