Question

How to delete a attachment in attachments collection using TFS api 2010, 2012. I only know wi.Attachments.Clear(); to delete all attachment.

Was it helpful?

Solution

How about this way? I tried and succeeded.

//wi is a WorkItem  
wi.Open();  
for (int i = wi.Attachments.Count - 1; i >= 0; i--)  
{  
    if (wi.Attachments[i].Name == "Attach1.txt")  
    wi.Attachments.RemoveAt(i);  
}  
wi.Save();
wi.Close();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top