.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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值