【发布时间】:2018-06-04 10:50:36
【问题描述】:
我想在 C# 的文档库中创建一些文件夹。
文档库中的文件夹结构应该如下:
"98_Projekte" --> "Muster Mandant" --> "01 测试子文件夹"
在我的 C# 代码中,我只在“98_Projekte”中创建子文件夹“Muster Mandant”。这是正确的,但我想之后在“Muster Mandant”中创建新的子文件夹(参见第二个 foreach)。
public static void AddFolder(ClientContext context, string[] folders)
{
Web web = context.Web;
var docLibrary = web.DefaultDocumentLibrary().RootFolder;
context.Load(docLibrary);
context.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.Folder subFolder in docLibrary.Folders)
{
if (subFolder.Name == "98_Projekte")
{
subFolder.Folders.Add("Muster Mandant");
context.ExecuteQuery();
docLibrary = subFolder;
docLibrary.Update();
}
}
foreach (Microsoft.SharePoint.Client.Folder subSubFolder in docLibrary.Folders)
{
if (subSubFolder.Name == "Muster Mandant")
{
foreach (string folder in folders)
{
subSubFolder.Folders.Add(folder);
}
}
}
context.ExecuteQuery();
}
}
你有什么解决办法吗?
【问题讨论】:
标签: c# sharepoint sharepoint-online