tags:

views:

117

answers:

2

I want attach a file to a work item of type bug.While saving bug details to server i have this attachement.can any body help me?

Thanks suneetha.

A: 

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
+1  A: 
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