我想在 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();
}
}
你有什么解决办法?
梦里花落0921
相关分类