tags:

views:

203

answers:

3

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

+1  A: 

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"

Ian Kemp
Thanks... its true, but I've discovered there is more to it than that... still I will mark your answer as correct, because at face value it is....
JL
A: 

Here is an interesting look at things : http://www.binarywave.com/blogs/eshupps/Lists/Posts/Post.aspx?ID=26

This tells you how to get to the file - beyond just the string as Ian Kemp mentioned.

As the author of this post rights, its totally illogical and a pain in the neck, but I guess... Just another reason why MOSS stinks.

JL
+1  A: 

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 ...
}
dahlbyk
Wish I saw this post of yours before I implemented the 1000 line version :)
JL