Frage

I want to refer to this question which shows how to create first-level folders: SharePoint Question

But I also need to know how to create Sub-Folders e.g. a Sub-Folder inside a List.

Does anyone know how to create Folders inside a List?

War es hilfreich?

Lösung

Try to use this

 foreach (SPListItem item in list.Folders)
                        {
                            if (item.Title == "yourfoldername")
                            {
                                SPListItem newItem = list.AddItem(item.Folder.ServerRelativeUrl, SPFileSystemObjectType.Folder);
                                newItem["Title"] = "SubFolder";
                                newItem.Update();
                            }
                        } 

Check the full code at Programmatically create a subfolder in SharePoint list

also you can add subfolder at specific folder by useing SPFolderCollection as the following

SPFolderCollection Col = oList.RootFolder.SubFolders;
SPFolder Folder = Col[foldername];
SPListItem newFolder = oList.AddItem(Folder.Url, SPFileSystemObjectType.Folder, newFolderName);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top