2

I want attach a file to a work item of type bug. While saving bug details to server I have this attachment.

riQQ
  • 9,878
  • 7
  • 49
  • 66

2 Answers2

8
TeamFoundationServer server = TeamFoundationServerFactory.GetServer("TFSRTM08");
WorkItemStore store = (WorkItemStore)server.GetService(typeof(WorkItemStore));
WorkItem workItem = store.Projects["ABC"].WorkItemTypes["Bug"].NewWorkItem();
//Set other work item properties.
workItem.Attachments.Add(new Attachment("C:\Temp\MyAttachment.txt", "Comment About Attachment"));
workItem.Save();
0

If you download the Visual Studio SDK, there should be an example in there for working with Work Items and attachments using the TFS API.

Martin Woodward
  • 11,770
  • 31
  • 45