Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Lists.DeleteAttachment Method

Windows SharePoint Services 3
Removes the attachment from the specified list item.

Web Service: ListsWeb Reference: http://<Site>/_vti_bin/Lists.asmx

[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/DeleteAttachment", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public void DeleteAttachment (
	string listName,
	string listItemID,
	string url



A string that contains either the title or GUID for the list.


A string that contains the ID of the item to delete. This value does not correspond to the index of the item within the collection of list items.


A string that contains the absolute URL for the attachment, as follows: http://Server_Name/Site_Name/Lists/List_Name/Attachments/Item_ID/FileName.

The URL to the attachment can be returned by using the GetAttachmentCollection method.

To access the Lists service and its methods, set a Web reference to http://Server_Name/[sites/][Site_Name/]_vti_bin/Lists.asmx.

The following code example deletes all the attachments for a specified item in a list on the current site.

This example requires that a using (Visual C#) or Imports (Visual Basic) directive be included for the System.Xml namespace.

Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;

XmlNode ndAttach = 
    listService.GetAttachmentCollection("List_Name", "1");
XmlNodeList ndsAttach = ndAttach.ChildNodes;

for (int i=0; i<ndsAttach.Count; i++)
    string delUrl = ndsAttach[i].InnerText;
    listService.DeleteAttachment("List_Name", "1", delUrl);

Community Additions

© 2015 Microsoft