I have a couple document libraries that are just standard libraries -- no associated custom content types or anything. I am trying to add subfolders to them, and in some cases it just doesn't work.
SPFolder parent = library.RootFolder;
SPFolder child = parent.SubFolders.Add(subfoldername);
parent.Update();
bool exists = child.Exists; // This is false
I can see that it seems to be data-dependent, but I'm still stumped. When I try to add a subfolder with this particular name via my code:
M1 Spectrum CRC w-out CMN67 E02_files
it fails to add the folder, even though the Add method seems to execute successfully. When I try to add a folder of this exact name via the standard browser-based SharePoint list UI, I successfully get a folder added, but it has a different name:
M1 Spectrum CRC w-out CMN67 E02_files_
Note the trailing underscore in the folder that SharePoint created for me. Why is it doing that? Why is this a particularly problematic case? This is a legal Windows folder name, and it doesn't contain any html-unfriendly characters. So, what's up with this? Am I missing something obvious?