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 :-)