I want attach a file to a work item of type bug
. While saving bug details to server I have this attachment.
Asked
Active
Viewed 6,302 times
2 Answers
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();

William D. Bartholomew
- 744
- 4
- 4
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