Saturday, 3 June 2017

How to get count of document libraries in a SharePoint site using SSOM?

To get the count of document libraries, we can use below simple code in SSOM:

using(SPSite site = new SPSite("https://yoursiteURL"))
{
  using (SPWeb web = site.OpenWeb())
  {
    SPListCollection librarycollection = Web.GetListsOfType(SPBaseType.DocumentLibrary);
    int count  = librarycollection .Count;
  }
}

Sweet and Simple. Hope this helps.!!!

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...