Thursday, August 27, 2009

Create SharePoint Document Library programmatically using C#

We can create our own custom document library programmatically, here is the code shown below

SPSite site = SPContext.Current.Site as SPSite;
SPWeb web = site.RootWeb as SPWeb;
try
{ //Create a new library as the permanent library
Guid customListID = web.Lists.Add("CUSTOM DOCUMENT LIBRARY", "CUSTOM DOCUMENT LIBRARY", SPListTemplateType.DocumentLibrary);
web.Update();
}

7 comments:

Anonymous said...

How can i put this into a visual studio solution.

rajkamal said...

Yes you can put

Harish said...

Can you help to integrate document management system in asp.net and how to use singal sign off

Unknown said...

Is it possible to create a document library within another document library? I would like to attached different automatic workflows to different document libraries within a main document library.

Is this possible thur GUI or programmatically?

Thanks,

John.

e signature said...

lif3 i am not sure about GUI but i think it must be possible through programming o think Rajkaml or any other expert can give a better outline of such a program.Have you written any code yourself

Silverfall said...

Hi Rajkamal
This was so useful...!!!
Thanks a lot and keep it up.

udaya said...

Hi,
I want to display this to Quick launch with the same name of Document Library,I am using below code..
docLib.OnQuickLaunch = true;

But it is not working can you please help me on that...
Thank you.