SharePoint 2010 如何取得ListItem的Attachements
最近一个项目用到读取SharePoint ListItem的attachments ,在网上找了很多资料终于知道了如何取得一个item的attachments,记录之,已被后用。
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;
....
}
浙公网安备 33010602011771号