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);
newListItem.Update();
documentLibrary.Update();
clientContext.ExecuteQuery();
}
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.
- “Invalid file name” error creating folder programmatically
- The file name you specified could not be used. It may be the name of an existing file or directory
- Renaming File in Library “Invalid File Name” Error
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.