Create Document Library using Client Object Model

sharepointsharepoint-2010sharepoint-clientobject

Just a quick question, is it possible to create a Document Library using the Client Object Model in SharePoint 2010?

I know you can create lists etc. Am I right in saying that a Document Library is just a 'special' type of List?

How can I specify that the List I create will be a Document Library?

Any help will be appreciated

Thanks

Best Answer

Yes. You can specify the TemplateType for your List.

List of TemplateTypes

using (ClientContext clientCTX = new ClientContext(url))
{
     ListCreationInformation lci = new ListCreationInformation();
     lci.Description = "My own DocLib";
     lci.Title = "Library";
     lci.TemplateType = 101;
     List newLib = clientCTX.Web.Lists.Add(lci);
     clientCTX.Load(newLib);
     clientCTX.ExecuteQuery();
}
Related Topic