Cracking down on Folders in SharePoint

Much has been said for and against using folders in lists and document libraries. Leaving these discussions aside, what if you want to disable folders entirely in a list or library? This post describes how you can remove the New + Folder menu from lists and libraries, but unfortunately this does not stop folders being created using other techniques.

For example, in a document library with the New + Folder menu removed, you can still create a folder by:

Use Actions + Open in Windows Explorer in the Document, Library, right-click and select New + Folder.

So, I’ve been on a quest to suppress these capabilities, but so far with no success. I’ve tried:

Using code and the class libraries to remove the hidden “Folder” content type. I can remove the content type, but folders can still be created.

Set the EnableFolderCreation property for the SPList object to false (this just does the same as removing the New + Folder menu command).

And other things…but to no success.

In many organisations imposing standards on how document libraries are used is important, and if a decision has been made not to use folders then this should be applied no matter how the user attempts to create the folder.

Firstly you need to implement the suggestions above – removing the Add Folder item from the menu.

Secondly you need a developer to attach an event receiver to the document library in question.

The ItemAdding event is triggered whenever someone tries to add an item to the list in question (by whatever means), and a folder is just a special content type within a list. ItemAdding is triggered BEFORE the item is added, and the operation can easily be cancelled ([C#] properties.Cancel = true;) before the folder is ever added. That ought to make it totally impossible to add a folder to the list.

When I create a Document Library programmatically on MOSS 2007, is there anyway to disable the “Folder creation” for that Doc.Lib programmatically?
It can be done, via Advance Settings and then disable.

Me too. It works as written. However, I want to get fancy and allow folders only for those in a super-privileged group (ECM) while disallowing for all others. I can’t make that seem to work. Using the following to detect membership…

…I then try to use this (lots of different ways attempted) to cancel the event only for those not in the group. This works fine for the New Folder link in the ribbon but is ignored for the WIndows Explorer route. I guess I just don’t understand how the latter works.