JG Vimalan's Blog

It is all about coding!

Create a document library programmatically

This method creates a document library programmatically. The SPWeb object and
the name of the document library to be created are passed as parameter.

 private SPList CreateDocumentLibrary(SPWeb spWeb, string docLibName)
        {           
            SPListTemplate template = //Get template object you want to use.           

            Guid listId = spWeb.Lists.Add(
                docLibName,
                string.Empty,
                template
                );

            SPList newDocLib = spWeb.Lists[listId];
            newDocLib.OnQuickLaunch = true; //show in quick launch
            newDocLib.Update();

            return newDocLib;  // returns the newly created document library object       
        }

Advertisements

September 27, 2010 - Posted by | SharePoint

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: