Create Document Library using Client Object Model
Asked Answered
P

2

8

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

Plyler answered 18/4, 2013 at 9:12 Comment(0)
T
8

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();
}
Tucana answered 18/4, 2013 at 9:33 Comment(0)
G
4

You can also set the templatetype with the following code, which I think makes things clearer to new programmers:

lci.TemplateType = (int) ListTemplateType.DocumentLibrary;
Gershom answered 24/5, 2017 at 13:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.