How to create a Modern Document Library in SharePoint 2010/2013/Online using CSOM?

Hello SharePointers,

Below is the CSOM to create a document library in Sharepoint online using CSOM . ListExperience.NewExperience is the property, we need to  set it up.

var SiteURL = @””;
var mylogin = “Laks@***”;
var mypassword = “****”;

var securePassword = new SecureString();

foreach (char c in password)
SharePointOnlineCredentials onlineCredentials = new SharePointOnlineCredentials(mylogin, mypassword);

ClientContext ctx = new ClientContext(SiteURL );
ctx.Credentials = onlineCredentials;
Web web = ctx.Web;

ListCreationInformation lci = new ListCreationInformation();
lci.Description = “Test Library”;
lci.Title = “Library”;
lci.TemplateType = 101;

List newLib = ctx.Web.Lists.Add(lci);

var createLibrary = ctx.Web.Lists.GetByTitle(“Library”);
createLibrary.ContentTypesEnabled = true;
createLibrary.ListExperienceOptions = ListExperience.NewExperience;

Happy SharePointing 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *