Wednesday 5 August 2015

Add folder in SharePoint list programatically

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();

}

No comments:

Post a Comment