public static void createLibrary()
{
string libraryName = "Test";
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
{
using (SPWeb oweb = osite.OpenWeb())
{
Guid listGuid = oweb.Lists.Add(libraryName,string.Empty, SPListTemplateType.DocumentLibrary);//SPListTemplateType.Will provide you all templates which can be created
SPList documentLibrary = oweb.Lists[listGuid];
documentLibrary.ContentTypesEnabled = true;
documentLibrary.OnQuickLaunch = true;
Console.WriteLine("Library created");
Console.ReadLine();
}
}
});
}
catch (Exception ex)
{
throw ex;
}
}
Result
No comments:
Post a Comment