Monday, 15 August 2011

CSharp.Net SharePoint List of Document Libraries using Client Context


This code will only return Document Libraries which are based on Template 101 ancestral type.


ClientContext clientContext = new ClientContext("http://mysharepoint");
Web oWebsite = clientContext.Web;
ListCollection collList = oWebsite.Lists;
clientContext.Load(collList);
clientContext.ExecuteQuery();
foreach (List oList in collList)
{
if ((oList.BaseType == BaseType.DocumentLibrary) && (oList.BaseTemplate == 101))
   {
     Do your actions here with oList.Title, oList.Title
   }
}

No comments:

Post a Comment