web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

On-Premise 2016 Plug-In Creating Folders and Sub-Folders in SharePoint site

(0) ShareShare
ReportReport
Posted on by 210

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)
  • ScottDurow Profile Picture
    21 on at
    RE: On-Premise 2016 Plug-In Creating Folders and Sub-Folders in SharePoint site

    You need to use something like:

    SPFolderCollection folders = site.GetFolder(url).SubFolders;

    folders.Add("SubFolder");

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans