.Net新建Sharepoint文件夹方法

 1 public static void AddSharepointFolder(ClientContext clientContext, string NewFolderName)
 2         {
 3             try
 4             {
 5                 Web web = clientContext.Site.RootWeb;
 6                 clientContext.Load(web);
 7                 clientContext.Load(web.Lists);
 8                 clientContext.Load(web, wb => wb.ServerRelativeUrl);
 9                 clientContext.ExecuteQuery();
10 
11                 List list = clientContext.Site.RootWeb.GetListByTitle(SPBackListName);
12                 clientContext.Load(list);
13                 clientContext.ExecuteQuery();
14 
15                 Folder folder = null;
16                 if (SPBackListFolderName == "")
17                 {
18                     folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + "/" + SPBackListWebName + "/");
19                 }
20                 else
21                 {
22                     folder = web.GetFolderByServerRelativeUrl(web.ServerRelativeUrl + "/" + SPBackListWebName + "/" + SPBackListFolderName + "/");
23                 }
24 
25                 clientContext.Load(folder);
26                 clientContext.ExecuteQuery();
27 
28                 if (folder != null)
29                 {
30                     ListItemCreationInformation creation = new ListItemCreationInformation();
31                     creation.FolderUrl = folder.ServerRelativeUrl;
32                     creation.UnderlyingObjectType = FileSystemObjectType.Folder;
33                     creation.LeafName = NewFolderName;
34 
35                     ListItem SubFolder = list.AddItem(creation);
36                     SubFolder.Update();
37 
38                     clientContext.ExecuteQuery();
39                 }
40             }
41             catch (Exception ex)
42             {
43 
44             }
45         }

原文出处

   

原文地址:https://www.cnblogs.com/61007257Steven/p/10640395.html