I want to create folder on SharePoint document library using client object model (C#). Below is the code which does that.

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"));


ContentType folderContentType = result.FirstOrDefault();

ListItemCreationInformation newItemInfo = new ListItemCreationInformation();
newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
newItemInfo.LeafName = Foldername;
ListItem newListItem = list.AddItem(newItemInfo);

newListItem["ContentTypeId"] = folderContentType.Id.ToString();
newListItem["Title"] = Foldername;


I need to create thousands of folders and am looking for a method that supports bulk operations, resulting in a single server call. Current method is time consuming as each request to create a folder is done individually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.