当我使用 Box, Inc c# sdk 一次创建多个文件夹时,我遇到了一个 javascript 错误。我一直在使用一个由路径和字符串列表组成的类作为子目录的路径。但是,当我调用 CreateBoxFolders 方法时,它会随机引发参数计数不匹配异常。到目前为止,我无法确定原因。
private void CreateBoxFolders(string dir, long boxfolderid)
{
string[] dirnames = dir.Path.Split('\\');
CreateBoxFolder(dirnames[dirnames.Count() - 1], boxfolderid);
long id = GetFolderId(dirnames[dirnames.Count() - 1], boxfolderid);
// This is a class with a list that stores the folder structure and path
dir.ChildDirectories.ForEach(x =>
CreateBoxFolders(x, id));
}
private void CreateBoxFolder(string name, long parent)
{
_BoxManager.CreateFolder(name, parent, false);
}
private long GetFolderId(string name, long parent)
{
var folders = _BoxManager.GetFolderStructure(parent,
BoxSync.Core.Primitives.RetrieveFolderStructureOptions.OneLevel);
long number = folders.Folder.Folders.Where(x => x.Name == name.Trim()).First().ID;
return number;
}