Dynamic nested folder creation using Blueprism

Hi Folks,

Hope you all doing good. Am facing some challenges in creating Nested folders using blueprism in code stage.

let me explain the process.

1. I have a list of folder names and sub-folder names in which i need to create and i have attached the screenshot for the same. Here column "Level" is nothin but depth of the folders.


2. Here in the list column "ID " starting for 1 to 7 is the first level folders. (ref: screenshot above).


3. And then from ID 8, 9, 10 are the second level folders to be created in ID 1 (Cloud and microservices). (ref: SS below).


4. And for the ID 11 is the third level to be created inside (Cloud Architecture concept).

Likewise i need folders irrespective of number of level and titles.

Code: C#

var levelsList = inCollection.AsEnumerable().Select(dItem => new {
Level = Convert.ToInt32(dItem["Level"])

var maxDepth = levelsList.Max(depth => depth.Level);

var maxDepthItems = inCollection.AsEnumerable().Where(dItem => Convert.ToInt32(dItem["Level"]) == maxDepth).ToList();

foreach(DataRow item in maxDepthItems)
var minDepthLevel = Convert.ToInt32(item["Level"]);
var parentId = Convert.ToInt32(item["Parent"]);
string folderPath = item.Field<string>("Name");

var depthEachItem = inCollection.AsEnumerable().Where(dItem => Convert.ToInt32(dItem["ID"]) == parentId).ToList().FirstOrDefault();
if(depthEachItem != null)
minDepthLevel = Convert.ToInt32(depthEachItem["Level"]);
parentId = Convert.ToInt32(depthEachItem["Parent"]);
folderPath = depthEachItem.Field<string>("Name") + "\\" + folderPath;
}while(minDepthLevel > 0);

string totalPath = inputBasePath + "\\" + folderPath;


While executing the code stage am not able to get the result as expected and only one folder is created as below.


Code Stage Input:


Namespaces and Dll used:


Could some help me to resolve this issue.

Thanks in Advance.

Karthick Krishnan