Friday, March 8, 2013

Add folders to list


This code to add folder to Pages list

    private void CreateFolderToPagesList(SPWeb oWeb)
        {            oWeb.AllowUnsafeUpdates = true;            string myFolderName = "myFolderName";
            SPList pageList = oWeb.Lists["Pages"];            foreach (SPListItem folder in pageList.Folders)            {                if(folder.Name.Equals(newsFolderName))                return;            }            SPListItem item = pageList.Items.Add("", SPFileSystemObjectType.Folder,myFolderName);            item.Update();            oWeb.AllowUnsafeUpdates = false;
        }

No comments:

Post a Comment