Monday, May 12, 2014

SharePoint 2010 / 2013: Create a document library with C#

This is how you create a document library with C# in a farm solution:

Guid myListID;
myListID = myWeb.Lists.Add("LibraryName", "Library Description", SPListTemplateType.DocumentLibrary);
myWeb.Update();
It's pretty easy and mostly self explanatory. I placed this in an event receiver so that I can create document libraries on feature activation. Works pretty good.

No comments:

Post a Comment