In this article I am going to explain or show you how to create a Document Library in SharePoint Server and how to add a folder in the Document Library by using C#:
To create a document library, follow these steps:
1) Open a browser and log into Sharepoint.
2) Click Site Actions and select More Options…
3) Under library, click Document Library and enter the document name as Personal Documents and click Create to proceed.
You can see that your Personal Document (Document Library) is create successfully in browser.
In the next step, we have to create a folder in a Document Library using C# application.
1) Open Visual Studio and create a Console Application.
2) Browse Microsoft.SharePoint.dll and it to the References.
3) In the next step you have to change the properties of an application.
4) In the build option change the platform target into 64 bit (x64).
1) Then write the below code in the Program.cs file.
static void Main(string args)
SPSite _MySite = new SPSite("http://rohit:34143/");
SPWeb _MyWeb = _MySite.OpenWeb();
SPDocumentLibrary _MyDocLibrary = (SPDocumentLibrary)_MyWeb.Lists["Personal
SPFolderCollection _MyFolders = _MyWeb.Folders;
string folderName = "rohitdoc";
_MyFolders.Add("http://rohit:34143/Personal%20Documents/" + folderName +
After create a document you can see your folder (rohitdoc) is successfully added in the Document library (Personal Documents).
Thanks for reading this article. I think this will help you a lot.