Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
Web Services
Lists Web Service
Lists Class
Lists Methods
 GetAttachmentCollection Method
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
Lists.GetAttachmentCollection Method (Lists)
Returns a list of the URLs for attachments to the specified item.

Web Service: ListsWeb Reference: http://<Site>/_vti_bin/Lists.asmx
Visual Basic (Declaration)
<SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetAttachmentCollection", RequestNamespace:="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace:="http://schemas.microsoft.com/sharepoint/soap/", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Function GetAttachmentCollection ( _
    listName As String, _
    listItemID As String _
) As XmlNode
Visual Basic (Usage)
Dim instance As Lists
Dim listName As String
Dim listItemID As String
Dim returnValue As XmlNode

returnValue = instance.GetAttachmentCollection(listName, listItemID)
C#
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetAttachmentCollection", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
public XmlNode GetAttachmentCollection (
    string listName,
    string listItemID
)

Parameters

listName

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

listItemID

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

Return Value

An XML fragment in the following form that contains the URLs for the attachments and that can be assigned to a System.Xml.XmlNode object.
Xml
<Attachments>
   <Attachment>http://Server_Name/LISTS/List_Name/
      Attachments/Item_ID/File1_Name</Attachment>
   <Attachment>http://Server_Name/LISTS/List_Name/
      Attachments/Item_ID/File2_Name</Attachment>
   <Attachment>http://Server_Name/LISTS/List_Name/
      Attachments/Item_ID/File3_Name</Attachment>
<Attachments>

The following code example displays the URLs of 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.

Visual Basic
Dim listService As New Web_Reference_Folder.Lists()
listService.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim ndAttach As XmlNode = 
    listService.GetAttachmentCollection("List_Name", "1")

MessageBox.Show(ndAttach.OuterXml) '
C#
Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists();
listService.Credentials= System.Net.CredentialCache.DefaultCredentials;

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

MessageBox.Show(ndAttach.OuterXml);
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker