SharePoint - Default Library Content Type is Folder

Ever enabled Content Types on a library, removed the default “Document” Content Type and then added your own document Content Type ? If you do it in that order it will set “Folder” as the Content Type for uploaded files.

There’s no apparent way in the user interface to change the default Content Type, since “Folder” is not visible in the list:

Change New Button Order and Default Content Type

If you don’t have a lot of lists already or you can only access SharePoint through the browser, the quickest way to fix this is to add the default “Document” Content Type to the list and immediately remove it again.

If (like in my case) you already have a lot of lists, you can script the Content Type Ordering:

using (SPSite site = new SPSite(url)) { foreach (SPWeb web in site.AllWebs) { foreach (SPList list in web.GetListsOfType(SPBaseType.DocumentLibrary)) { if (list.ContentTypes["Main Document"] != null) { SPFolder folder = list.RootFolder; List<SPContentType> lstCT = new List<SPContentType>(); lstCT.Add(list.ContentTypes["Main Document"]); folder.UniqueContentTypeOrder = lstCT; folder.Update(); } } web.Close(); } }

The above code loops all libraries on all sites in a Site Collection and sets my “Main Document” Content Type as the only (and default) Content Type. If you have different needs feel free to adapt as required.



Wednesday, 18 Sep 2013 08:39 by Slava Gorbunov
Thanks for the post! Interesting issue. Posted the description of what I am experiencing here: Now I know how to resolve it. Thanks. :)

CAPTCHA Image Validation