我需要使用客户端对象模型在 sharepoint 中创建子文件夹,父文件夹存在,这是我的代码,但出现此错误,
无效的文件名。您指定的文件名无法使用。它可能是现有文件或目录的名称,或者您可能没有访问该文件的权限。
ContentTypeCollection listContentTypes = list.ContentTypes;
clientContext.Load(listContentTypes, types => types.Include
(type => type.Id, type => type.Name,
type => type.Parent));
var result = clientContext.LoadQuery(listContentTypes.Where
(c => c.Name == "Folder"));
clientContext.ExecuteQuery();
ContentType folderContentType = result.FirstOrDefault();
ListItemCreationInformation newItem = new ListItemCreationInformation();
newItem.UnderlyingObjectType = FileSystemObjectType.Folder;
newItem.FolderUrl = @"http://mysite/sites/org" + "/" + listName;
if (!folderName1.Equals(string.Empty))
{
newItem.FolderUrl += "/" + folderName1;
}
newItem.LeafName = folderName2;
ListItem item = list.AddItem(newItem);
item["ContentTypeId"] = folderContentType.Id.ToString();
item["Title"] = folderName2;
item.Update();
clientContext.Load(list);
clientContext.ExecuteQuery();