SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
SPList list = web.GetList(SPUrlUtility.CombineUrl(web.Url, listUrl);
SPListItem item = list.GetItemById(1);
SPAttachmentCollection attachmentCollection = item.Attachments;
List<String> attachmentsList = new List<string>();
for (int i = 0; i < attachmentCollection.Count; i++)
{
attachmentsList.Add(attachmentCollection[i]);
}
for (int i = 0; i < attachmentList.Count; i++)
{
item.Attachments.Recycle(attachmentList[i]);
}
item.Update();
web.AllowUnsafeUpdates = true;
SPList list = web.GetList(SPUrlUtility.CombineUrl(web.Url, listUrl);
SPListItem item = list.GetItemById(1);
SPAttachmentCollection attachmentCollection = item.Attachments;
List<String> attachmentsList = new List<string>();
for (int i = 0; i < attachmentCollection.Count; i++)
{
attachmentsList.Add(attachmentCollection[i]);
}
for (int i = 0; i < attachmentList.Count; i++)
{
item.Attachments.Recycle(attachmentList[i]);
}
item.Update();