using (SPSite site = new SPSite(@"http://moss2010/WorkFlowCenter"))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["Booking"];
SPListItem item = list.GetItemById(10);
SPAttachmentCollection attachmentCollection = item.Attachments;
List<String> attachmentList = new List<string>();
for (int i = 0; i < attachmentCollection.Count; i++)
{
attachmentList.Add(attachmentCollection[i]);
}
for (int i = 0; i < attachmentList.Count; i++)
{
item.Attachments.Recycle(attachmentList[i]);
}
item.Update();
}
}
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["Booking"];
SPListItem item = list.GetItemById(10);
SPAttachmentCollection attachmentCollection = item.Attachments;
List<String> attachmentList = new List<string>();
for (int i = 0; i < attachmentCollection.Count; i++)
{
attachmentList.Add(attachmentCollection[i]);
}
for (int i = 0; i < attachmentList.Count; i++)
{
item.Attachments.Recycle(attachmentList[i]);
}
item.Update();
}
}