以编程方式将所有文档从一个sharepoint文档列表复制到另一个文档列表的最佳方法是什么?
答案 0 :(得分:2)
找到解决方案:
SPDocumentLibrary fromList = (SPDocumentLibrary)SPContext.Current.Site.RootWeb.Lists.TryGetList(ListNames.DocmentListName);
SPWeb currentWeb = SPContext.Current.Web;
SPDocumentLibrary toList = (SPDocumentLibrary)currentWeb.Lists.TryGetList(ListNames.DocmentListName);
SPFileCollection collection = fromList.RootFolder.Files;
foreach (SPFile item in collection)
{
toList.RootFolder.Files.Add(item.Url, item.OpenBinary());
}