SharePoint 2010 如何取得ListItem的Attachements

最近一个项目用到读取SharePoint ListItemattachments ,在网上找了很多资料终于知道了如何取得一个itemattachments,记录之,已被后用。

string sourceInitialName =  sourceList.DefaultViewUrl.Substring(7,index-7);//取得列表名称

SPListItem sourceItem = sourceList.GetItemById(SourceItemID);//取得Item

SPFolder sourceListAttFolder = sourceItem.Web.Folders["Lists"].SubFolders[sourceInitialName].SubFolders["Attachments"].SubFolders[sourceItem.ID.ToString()];
//取得item的附件所在文件夹集合 

//循环处理逻辑
foreach (SPFile AttFile in sourceListAttFolder.Files)
{
    byte[] binFile = AttFile.OpenBinary();
    string copiedFileName = AttFile.Name;
      ....
}

posted on 2011-08-15 11:28  张大明  阅读(332)  评论(0编辑  收藏  举报

导航