Dynamic nested folder creation using Blueprism

Sreekar

New Member
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.

1602487180152.png

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

1602487229081.png

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).

1602487252603.png

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"])
}).ToList();

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");

do
{
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;

if(!Directory.Exists(totalPath)){
Directory.CreateDirectory(totalPath);
}
}


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

1602487112980.png


Code Stage Input:

1602487469475.png

Namespaces and Dll used:

1602487576302.png

Could some help me to resolve this issue.

Thanks in Advance.

Karthick Krishnan
 

Attachments

  • 1602487157187.png
    1602487157187.png
    4.9 KB · Views: 6
Top