我可以将附件保存到WorkItem,如下所示:
TfsTeamProjectCollection tfsTeamProjects = new TfsTeamProjectCollection(new Uri(tfsServerUrl));
WorkItemStore tfsWorkItemStore = tfsTeamProjects.GetService<WorkItemStore>();
WorkItem tfsWorkItem = tfsWorkItemStore.GetWorkItem(tfsWorkItemId);
FileInfo fi = new FileInfo(@"D:\\Docs\testfile.txt");
Attachment tfsAttachment = new Attachment(fi.FullName);
tfsWorkItem.Attachments.Add(tfsAttachment);
tfsWorkItem.Save();但是当我尝试获取WorkItem的附件列表时,如下所示:
TfsTeamProjectCollection tfsTeamProjects = new TfsTeamProjectCollection(new Uri(tfsServerUrl));
WorkItemStore tfsWorkItemStore = tfsTeamProjects.GetService<WorkItemStore>();
WorkItem tfsWorkItem = tfsWorkItemStore.GetWorkItem(tfsWorkItemId);
foreach(Attachment tfsAttachment : tfsWorkItem.Attachments)
{
// Do things here
}tfsWorkItem.Attachments总是空的,即使我可以在TFS上的Objects选项卡中看到四个附件。我得到的WorkItem对象是正确的。
https://stackoverflow.com/questions/44410759
复制相似问题