Sharepoint:SPAttachmentCollection究竟是什么集合?

JL.*_*JL. 4 c# sharepoint

请使用以下代码段:

SPAttachmentCollection attachments = item.Attachments ; 
Run Code Online (Sandbox Code Playgroud)

SPAttachmentCollection究竟是一个什么样的集合?大多数收藏品告诉你它们是什么......但是要记住SharePoint的黄金法则 - 这是正确的,如果它可能会破坏,它已经被破坏了.

如果您想知道SPAttachment对象不存在.那么有人可以赐教,我正在寻找的附件对象是什么.

谢谢

dah*_*byk 19

请注意,链接的帖子会使事情复杂化.首选用法可在评论中找到:

var attachments in item.Attachments;
foreach (string fileName in attachments)
{
    SPFile file = web.GetFile(attachments.UrlPrefix + fileName);
    // Do something ...
}
Run Code Online (Sandbox Code Playgroud)


Ian*_*emp 2

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

“SPAttachmentCollection 只是一个表示每个附件的文件名的字符串数组”