Progammatically Adding Folders to a SharePoint List
This took me longer than it should have to get working as the things I tried first compiled but did nothing:
myList.Folders.Add("DoesNotWork", SPFileSystemObjectType.Folder);
The way I got it to work in the end was like this:
SPList myList = myWeb.Lists["My List"]; SPListItem newFolder = myList.Items.Add(myList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, null); if (newFolder != null) { newFolder["Name"] = "Name of Folder"; newFolder.Update(); }
Hope this helps somebody :-)
Comments
- Anonymous
August 30, 2007
PingBack from http://msdnrss.thecoderblogs.com/2007/08/30/progammatically-adding-folders-to-a-sharepoint-list/