我正在尝试以以下方式创建一组来自平面文件的文件夹。
X/Y/Z
我想为每一个创建一个目录,但我对递归的记忆让我陷入了困境。
这是我的代码有人可以建议。
public void CreateDirectory(SPFolderCollection oWeb, string folder)
{
SPFolder theFolder = oWeb.Add(folder);
theFolder.Update();
}
public void FolderCreator(SPWeb oWeb)
{
StreamReader reader = new StreamReader(this.txtFolders.Text);
while (reader.Peek() != -1)
{
string folderLine = reader.ReadLine();
if (folderLine.Contains("/"))
{
SPFolderCollection collection = oWeb.Folders["Documents"].SubFolders[folderLine.Split('/')[0]].SubFolders;
CreateDirectory(collection, folderLine);
}
SPFolderCollection newCollection = oWeb.Folders["Documents"].SubFolders;
CreateDirectory(newCollection, folderLine);
}
}
这不起作用我正在寻找它来做recrusion所以如果我通过
ABC/DEF/GHI 和 ABC/DEF 它将去适当地创建文件夹。
但我被困在如何做到这一点上。