SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Usually when we need to get all the document libraries from a SharePoint site, we can follow the given code snippet:-

SPListCollection lstCol = oSite.OpenWeb().GetListsOfType(SPBaseType.DocumentLibrary);

But how to get the same result using SharePoint Client Object Model? Thanks in advance...:)

share|improve this question
up vote 3 down vote accepted

Hi u just get all list from site and just check it's BaseType like this

using (ClientContext clientcontext= new ClientContext("http://your server"))

    //Load Libraries from SharePoint
    foreach (List list in clientcontext.Web.Lists)
            if (list.BaseType.ToString() == "DocumentLibrary")
                 // here u get all document library
share|improve this answer
Thanks V_B.Thanks a lot...:) – DeathRider Aug 27 '12 at 12:22

This is better as it only pulls back the document libraries rather than all the lists which you then have to check in a loop.

 var Libraries = clientContext.LoadQuery(Web.Lists.Where(l => l.BaseTemplate == 101));

Also note that I've used the BaseTemplate property which has more granularity than BaseType. You can get ListTemplate enumeration values which map to the CSOM BaseTemplate property from here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.