Online Training On SharePoint

Sunday, 2 November 2008

Hiding Site Collection Documents and Site Collection Images Libraries In SharePoint

Recently we got a requirment where we either need to hide/delete "Site Collection Documents", "Site Collection Images" Libraries from the viewlsts.aspx page. Users should not be able to access these libraries from this page.
While trying to delete these sites we realised that delete option for these libraries is not visible from the GUI. When we attempted to delete with the SharePoint Designe we got the error:
“Server Error: The folder selected for deletion contains one or more lists, document libraries, or galleries that your web site requires in order to function correctly. Therefore, you cannot delete the folder.” So there was no easy way for us to delete these libraries.
Then we started trying to hide these libraries. Hiding of these libraries is possible with SPList.Hidden property in the SharePoint user interface. Following is the code snippet with which the libraries were hided:

SPSite site = new SPSite(http://localhost/);
SPWeb web = site.OpenWeb();
SPList list = web.Lists["Site Collection Documents"];
list.Hidden = true;
list = web.Lists["Site Collection Images"];
list.Hidden = true;

Post a Comment
Related Posts with Thumbnails