如何从Microsoft.TeamFoundation.WorkItemTracking.Client.Workitem的实例开始检索工作项的附加文件的名称?
答案 0 :(得分:0)
您可以使用以下示例从特定工作项中检索附件的名称:
已安装Nuget软件包Microsoft.TeamFoundationServer.ExtendedClient。
using System;
using Microsoft.VisualStudio.Services.Client;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace RetrieveAttachmentName
{
class Program
{
static void Main(string[] args)
{
var u = new Uri("http://server:8080/tfs/DefaultCollection");
var c = new VssClientCredentials();
int workitemid = 78;
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(u, c);
tpc.EnsureAuthenticated();
WorkItemStore wistore = tpc.GetService<WorkItemStore>();
WorkItem wi = wistore.GetWorkItem(workitemid);
var file1 = wi.Attachments[0].Name;
var file2 = wi.Attachments[1].Name;
//var file3 = wi.Attachments[2].Name;
//...
Console.WriteLine(String.Format("{0}\n{1}", file1, file2));
Console.ReadLine();
}
}
}