I am trying to create a folder in Document Library in SharePoint 2010 using Client Side Object Model C#.

I am using following code:

using (ClientContext clientContext = new ClientContext(siteUrl))
  List documentLibrary = clientContext.Web.Lists.GetByTitle(documentLibraryName);

  ListItemCreationInformation newItemInfo = new ListItemCreationInformation();
  newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
  newItemInfo.LeafName = inventionFolderName;
  newItemInfo.FolderUrl = siteUrl + documentLibraryName;

  ListItem newListItem = documentLibrary.AddItem(newItemInfo);

From last few days it was working fine. But today its stopped working. And I am not able to figure it out the actual reason.

What I have checked?

Checked both level recycle bin to ensure that the folder name should not exists there.

Also tried with random folder names but the error was the same.

If any one have gone through the above error then please suggest the possible cause to this error.

I have already gone through following posts but it does not helped me.

What I tried:

I tried with following data

Document Library Name : Inventions SK-00100 to SK-05805

Folder Name : SK-00100

It gives error. While when I tried with

Document Library Name : Library-1

Folder Name : SK-00100

It doesn't throws the error.

I am confused now.

1 Answer 1


Use following code to add folder in library

Folder folder = documentLibrary.RootFolder.Folders.Add(sourceFolder.Name);
  • 1
    The code given in your answer is correct, but I wanted to know what's the problem with my code. because it was working fine till now and all my further tasks are based upon my code. If I replace my code with new code then it will be a lots of changes. Aug 30, 2016 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.