TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Programmatically Creating Folders within SharePoint List
Rajkiran Swain
Apr 29
2015
Code
924
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
using (SPSite oSPsite =
new
SPSite(“http:
//website_url”))
{
oSPsite.AllowUnsafeUpdates =
true
;
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
oSPWeb.AllowUnsafeUpdates =
true
;
/* Path within the list where the new folder gets created
Leave it empty if it needs to be created under root */
String nodeDepthPath = @”/MyRootFolder”;
/* get the list instance by name */
SPList list = oSPWeb.Lists[“List_Name”];
/* create a folder under the path specified */
SPListItem folderItem = list.Items.Add(
list.RootFolder.ServerRelativeUrl + nodeDepthPath,
SPFileSystemObjectType.Folder);
/* set the folder name and update */
folderItem[“Title”] = “New_Folder_Name”;
folderItem.Update();
oSPWeb.AllowUnsafeUpdates =
false
;
}
oSPsite.AllowUnsafeUpdates =
false
;
}
SharePoint
SharePoint List
Create Folders