Creating a document library using a client object model

Just a quick question: is it possible to create a document library using the client object model in SharePoint 2010?

I know that you can create lists, etc. Am I right in saying that a document library is just a "special" type of list?

How can I indicate that the List being created will be a document library?

Any help would be appreciated

thanks

+7
source share
2 answers

Yes. You can specify a TemplateType for the List .

TemplateTypes List

 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(); } 
+7
source

You can also set the templatetype type with the following code, which I think makes it easier to work with new programmers:

 lci.TemplateType = (int) ListTemplateType.DocumentLibrary; 
+1
source

All Articles