I have a requirement for a plugin that will create folders or sub-folders within a SharePoint Library when a records are created.
I can create the root folder with this code - works wonderfully....
Microsoft.SharePoint.Client.List docs = web.Lists.GetByTitle("Shared Documents");
FolderCollection folderColl = docs.RootFolder.Folders; Folder newFolder = folderColl.Add("FolderLevel1"); web.Context.Load(newFolder); web.Context.ExecuteQuery();
I am having trouble creating folders under FolderLevel1- When I am on a child entity of the FolderLevel1 I want to create the sub-folder thus in Shared Documents I have FolderLevel1 already existing and I need to add a sub folder FolderLevel2.
I'm unsure how to "find" FolderLeve11 so that I can do an add of the sub-folder. Google is showing examples of building all folders at the same time. In my case I am only creating the sub-folder.
Any guidance would be appreciated.
Diane
*This post is locked for comments
I have the same question (0)You need to use something like:
SPFolderCollection folders = site.GetFolder(url).SubFolders;
folders.Add("SubFolder");
Aric Levin - MVP
2
Moderator
MA-04060624-0
1