开发者

SharePoint 2010: Copy documents between lists

What is the best way to copy all documents from one sharep开发者_JS百科oint document list to another programmatically?


Found a solution:

            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());
            }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜