IFS二次开发03——Item

在TFS 中把每个文件夹被抽象成“ItemSet”或“Item”,相对于父级目录来讲就是Item ,相对于子级目录来讲就是“ItemSet”。每个文件都被抽象成“Item”。

 

//连接TFS
string tpcURL = "http://192.168.83.62:8080";
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tpcURL));
VersionControlServer version = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer;

//获取指定目录下的Item
String Path="$/"  ;         
ItemSet its = version.GetItems("$/", RecursionType.OneLevel); //获取Path 下的所有Item, 包括Path 自己,并且是第一个。第一个参数支持通配符,如:ItemSet its = version.GetItems("$/*.xaml", RecursionType.OneLevel);
// RecursionType.OneLevel 递归向下读取一层 // RecursionType.Full 递归读取所有 // RecursionType.None 不递归
//遍历Item foreach (Item item in its.Items) { //item.ArtifactUri 在服务器上的绝对路径 如:http://192.168.82.63:88/######## //item.ItemType 枚举,表明是文件还是文件 //item.ServerItem 在服务器上的绝对路径 如:$/CtripSolution/CommDll // item.IsBranch 是否是分支 //item.DownloadFile() 下载到本地 //.........
}

结合上面的代码,我们可以做出下面的效果:

 

 //显示已经删除掉的Item
string tpcURL = "http://192.168.83.62:8080"; TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tpcURL)); VersionControlServer version = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer; ItemSpec spec = new ItemSpec("$/CtripSolution/Customer/MAINLINE/ScrmApp/SinaWeiTravel", RecursionType.Full); var deletedItems = version.GetItems(spec, VersionSpec.Latest, DeletedState.Deleted, ItemType.Any, true);
原文地址:https://www.cnblogs.com/xumingxiang/p/3101626.html