Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

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

  • ScottDurow Profile Picture
    ScottDurow 50,177 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans