C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How To Create A Document Library In SharePoint 2013 Programmatically
WhatsApp
Manpreet Singh
8y
22.3
k
0
0
25
Blog
Welcome to a blog on how to create a Document Library in SharePoint 2013 programmatically, using a Console Application. We will use Visual Studio to create a Document Library in SharePoint 2013 site.
Let’s see, how to do it.
Open your Visual Studio.
Select New Project.
Select Console Application.
Add the references, Microsoft.SharePoint dll and Microsoft.SharePoint.Client dll.
Paste the code, given below, under Program.cs.
Code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Security;
using
System.Net;
using
System.Text;
using
System.Web;
using
System.Data;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.Client;
namespace
ConsoleApplication1 {
class
Program {
static
void
Main(
string
[] args) {
//get the web
ClientContext context =
new
ClientContext(
"Provide your site url"
);
Web web = context.Web;
//provide the document library information as Title and Description
ListCreationInformation createLibrary =
new
ListCreationInformation();
createLibrary.Title =
"My Doc Lib"
;
createLibrary.Description =
"My Document Library"
;
//choose a template as Document Library.
createLibrary.TemplateType = (
int
) ListTemplateType.DocumentLibrary;
//add library to SharePoint
web.Lists.Add(createLibrary);
context.ExecuteQuery();
Console.WriteLine(
"Document Libarary Created"
);
Console.ReadKey();
}
}
Run the code and your Document Library will be created.
Document Library
SharePoint 2013 Programmatically
SharePoint
Recommended related topics
Membership not found