Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SharePoint SPFolder.SubFolders.Add not actually adding a folder

I have a couple of 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

When I try to add a subfolder called M1 Spectrum CRC w-out CMN67 E02_files via code 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. 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?

like image 343
Chris Farmer Avatar asked Jun 24 '09 20:06

Chris Farmer


People also ask

What is the difference between a library and a folder in SharePoint?

The document library is a “container” into which documents are placed. Folders can be created within a document library for further organization. Documents are stored on the server, so they're easily accessible and editable by members of the site.

How do I restrict access to subfolders in OneDrive?

You can manage sharing of your OneDrive file or folder in more detail by selecting the option, “Manage access” when you right click on a file or folder.


1 Answers

This is because a folder ending with _files is a special kind created by the MS Office client apps when saving a document as HTML. The Office apps saves all the Web page resource files like images and css files to this folder. But it cannot be manipulated through the SharePoint Object Model - a real mess if you ask me! Only solution for you is to NOT create folders ending with _files.

like image 150
Lars Fastrup Avatar answered Nov 15 '22 17:11

Lars Fastrup