I am trying to create a new folder within a document library. Actually, the code works well, but when the title of the new folder starts with a blank, I get an exception "File not found" and the folder is not created.
I already tried to encode the title: replaced the blach by "%20"
and by "+"
. In this case the folder is created, but it contains other characters like"+"
at the first position in the title.
I tried to create the folder " blankBefore" in the SharePoint application by using the browser - and it works. The folder is create and looks like this " blankBefore".
I can create folders with a blank in the title, but not, if the title of the folder starts with a blank.
public bool CreateFolder(SharePointNode spParentNode, string strFolderName)
{
ClientContext localCTX = new ClientContext(spParentNode.ParentSite);
ConectClient(localCTX);
Folder newFolder = null;
var folder = localCTX.Web.GetFolderByServerRelativeUrl(spParentNode.URL);
localCTX.Load(folder);
localCTX.Load(folder.Folders);
Folder newFolder = folder.Folders.Add(strFolderName);
newFolder.Update();
localCTX.ExecuteQuery();
return true;
}