Below is the code snippet to add folder in SharePoint list
SPList lst = web.GetList("ListRelativePath");
if (lst != null)
{
SPContentType spContTyp =lst.ContentTypes["Folder Content Type Name"];
SPListItem folderItem = lst.Items.Add(lst.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder);
folderItem["Title"] = "foldername";
folderItem.Update();
}
SPList lst = web.GetList("ListRelativePath");
if (lst != null)
{
SPContentType spContTyp =lst.ContentTypes["Folder Content Type Name"];
SPListItem folderItem = lst.Items.Add(lst.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder);
folderItem["Title"] = "foldername";
folderItem.Update();
}
No comments:
Post a Comment