下图是在VS2010里创建Label的界面

可以看出创建Label 需要如下参数:Name、Comment、Path、Version 。
下面是代码实现:

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client; string tpcURL = "http://127.0.0.1:8080/";
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tpcURL));
VersionControlServer versionControl = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer; //创建标签
string labelName = "标签名称";
string labelComment = "标签评论";
string path = "$/CRM/Branches/WeiMovie";
VersionSpec version = VersionSpec.Latest;
var versionControlLabel = new VersionControlLabel(versionControl, labelName, versionControl.AuthorizedUser, path, labelComment); //Represents one or more files or folders on the local machine or in the repository.
var itemSpec = new ItemSpec(path, RecursionType.Full);
var labelItemSpec = new LabelItemSpec[];
labelItemSpec[] = new LabelItemSpec(itemSpec, version, false);
var lb = versionControl.CreateLabel(versionControlLabel, labelItemSpec, LabelChildOption.Merge);
//查询标签
VersionControlLabel[] lbls = versionControl.QueryLabels(null, null, null, true);//查询全部标签
//VersionControlLabel[] lbls = version.QueryLabels(null, null, null, false, path, VersionSpec.Latest);// 查询指定路径的标签
//删除标签
versionControl.DeleteLabel(lbls[].Name, lbls[].Scope);

最新文章

  1. [ASP.NET]书店后台开发-模板页
  2. 如何预览github中的html页面
  3. C#自定义控件
  4. http://jingyan.baidu.com/article/86112f13582848273797879b.html
  5. Mac OS 快捷键
  6. 编译器失败,错误代码为xxx
  7. poj 2265 Bee Maja
  8. 基于Spring Boot构建的Spring MVC快速入门
  9. android编译系统的makefile文件Android.mk写法如下
  10. WCF技术剖析之二十七: 如何将一个服务发布成WSDL[基于WS-MEX的实现](提供模拟程序)
  11. 如何实现vue前端跨域,proxyTable解决开发环境前端跨域问题
  12. VS 使用vs2017自带的诊断工具(Diagnostic Tools)诊断程序的内存问题
  13. pythn print格式化输出---------"%s 和 % d" 都是什么意思?
  14. Coroutine的原理以及实现
  15. 专访笨叔叔:2019年可能是Linux年?(转)
  16. Java代码优化小结(一)
  17. Nginx ACCESS阶段 统一的用户权限验证系统
  18. Leetcode 999. 车的可用捕获量
  19. ssm介绍
  20. Properties类、序列化流与反序列化流、打印流、commons-IO

热门文章

  1. Linux系统安装workerman,启动wss 服务
  2. 使用Ajax long polling实现简单的聊天程序
  3. css counter的使用方法
  4. python的输出问题
  5. zabbix添加对tomcat线程池的监控
  6. 【ArcGIS】ArcGIS Data Store配置
  7. scala函数demo
  8. windows命令行下用netsh实现端口转发(端口映射)
  9. TYAttributedLabel——简单,强大的iOS属性文本控件
  10. codeforces水题100道 第二题 Codeforces Beta Round #4 (Div. 2 Only) A. Watermelon (math)