开发者

SharePoint 2010: Copy documents between lists

开发者 https://www.devze.com 2023-01-06 08:51 出处:网络
What is the best way to copy all documents from one sharep开发者_JS百科oint document list to another programmatically?Found a solution:

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

精彩评论

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

关注公众号