Nick Grattan’s SharePoint Blog

About Microsoft SharePoint and some .NET

Cracking down on Folders in SharePoint

with 10 comments

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:

  1. Use Actions + Open in Windows Explorer in the Document, Library, right-click and select New + Folder.
  2. In Microsoft Word, choose File + Save, navigate to the SharePoint document library, right-click and choose New + Folder.

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

  1. 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.
  2. Set the EnableFolderCreation property for the SPList object to false (this just does the same as removing the New + Folder menu command).
  3. 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.

Any other ideas? 

Written by Nick Grattan

December 2, 2007 at 6:50 pm

10 Responses

Subscribe to comments with RSS.

  1. how about a demerit for every folder creation offense? :) I’ve been trying to figure out the same thing for myself, no luck yet though other than verbally stating that sub folders are not to be used.

    Henry

    December 7, 2007 at 5:24 am

  2. Best answer I’ve had to this problem! Nick

    nickgrattan

    December 17, 2007 at 2:49 pm

  3. With regards to this matter, i am researching a way to give users access to create documents but not create folders. Any workarounds around this?

    Nicholas

    January 18, 2008 at 2:27 am

  4. 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.

    SamV

    January 30, 2008 at 12:46 pm

  5. 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.

    Is there anyway that it can be done “programmatically” ?

    mInNaL

    February 12, 2008 at 11:32 pm

  6. FYI: If you want to access the content type from the ItemAdding method, use the AfterProperties:

    if (((string)properties.AfterProperties["ContentType"]) == “Folder”)
    {
    // put code here
    }

    gbelzile

    February 20, 2008 at 3:53 pm

  7. would removing the new folder content type from your site collection remove the ability to create folders in doc libs.

    erugalatha

    May 2, 2008 at 10:56 am

  8. Thanks for the suggestion. Don’t think you can – the “Folder” content type is “sealed” and cannot be deleted. Nick.

    nickgrattan

    May 2, 2008 at 11:25 am

  9. In my case, I had a folder in which I didn’t wanna let anothers to be create, only a custom content type I had made. I used this:

    //Create a list with the available contentTypes
    List cTypes = new List();
    cTypes.Add(atividadeCType);

    //Set the content types available to the folder
    properties.ListItem.Folder.UniqueContentTypeOrder = cTypes;
    properties.ListItem.Folder.Update();

    Properties comes in the itemAdded event and atividadeCtype is my custom content type.

    Anselmo

    July 15, 2008 at 5:34 pm

  10. Has anyone found a solution for this problem?

    Tony

    August 18, 2009 at 11:37 am


Leave a Reply