Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Creating DocLib Thru SP Object

  Asked By: Demarco    Date: Aug 02    Category: Sharepoint    Views: 3181

Does anyone know how to create DocLib using SharePoint OM ? (WSS 3.0)

I couldn't find any SPClass that mention it.



1 Answer Found

Answer #1    Answered By: Percy Beach     Answered On: Aug 02

Here is a quick and dirty snippet of code to add a new document library to a

string docLibName = "NewDocLib3";

string docLibDesc = "This is a new doc lib";

SPSite aSite = new SPSite("http://localhost "); //use full URL to
site or subsite here

SPWeb aWeb = aSite.OpenWeb();

SPListCollection aLists = aWeb.Lists;

SPListTemplateCollection spltc = aWeb.ListTemplates;

SPListTemplate splt = spltc["Document Library"];

aWeb.AllowUnsafeUpdates = true;

aLists.Add(docLibName, docLibDesc, splt);

aWeb.AllowUnsafeUpdates = false;

Didn't find what you were looking for? Find more on Creating DocLib Thru SP Object Or get search suggestion and latest updates.