Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharepoint: SPAttachmentCollection a collection of what exactly?

Tags:

c#

sharepoint

Take the following code snippet:

SPAttachmentCollection attachments = item.Attachments ; 

What exactly is SPAttachmentCollection a collection of? Most collections tell you what they're a collection of.... but remember the golden rule of SharePoint - that's right, if its possible to break, its already broken.

In case you're wondering an SPAttachment object does not exist. So could someone please enlighten me, what is the attachment object I am looking for.

Thanks

like image 294
JL. Avatar asked Nov 30 '22 19:11

JL.


2 Answers

Note that the linked post complicates things. The preferred usage is found in the comments:

var attachments in item.Attachments;
foreach (string fileName in attachments)
{
    SPFile file = web.GetFile(attachments.UrlPrefix + fileName);
    // Do something ...
}
like image 106
dahlbyk Avatar answered Dec 06 '22 11:12

dahlbyk


http://www.binarywave.com/blogs/eshupps/Lists/Posts/Post.aspx?ID=26

"the SPAttachmentCollection is simply an array of strings representing the file name of each attachment"

like image 40
Ian Kemp Avatar answered Dec 06 '22 11:12

Ian Kemp