Want to become a Vibe Coder? Join Vibe Coding Training here
x
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
Programmatically Creating Folders within SharePoint List
WhatsApp
Rajkiran Swain
Apr 29
2015
1.1
k
0
0
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
Up Next
Programmatically Creating Folders within SharePoint List