How can i Extract the entire folder hierarchy

@Soudios pass the below in the ArrayRow

foldername.ToString.Split({""c},StringSplitOptions.RemoveEmptyEntries).ToArray()

datatable use your build datatable output

cheers

the final result is not what i want, i have the full path and i just need the folders and files,also it doesnt takes all the files into the folders

@Soudios

you want to write the entire data like EmptyFolder Name and also Files in a Folder if present

or can you share me your excpected output

Or Share your xaml i will solve it and get back to you
I will do it with sample folders

the urgent issue to solve is to have all the folder even when its empty

@Soudios

foldercase.xaml (17.5 KB)

Can you look into this

the format is not good, use this :

Directory.GetDirectories(str_parentDirectory,“*”,SearchOption.AllDirectories).
SelectMany(Function(s) Directory.GetFiles(s.ToString)).
Select(Function(s) s.ToString.Replace(str_parentDirectory+“",”")).
ToArray()

Also the line is empty i can’t see the name’s empty folder

@Soudios

The above format give you the all array of files which are present in the all the subfolders

then How can you know which folder is empty?

because i know my folders and i checked after the folder i create empty for the test

@Soudios

For empty folder you will not get any files, Then how can you know that which folder is empty

by using your syntax

please share the dummy folders and expected output excel

I will share the code

i want the hierarchy with ou without files into

@Soudios

If you want to check whether the each sub folder contains files or not

if present you want use for each file and inside add the data to excel

if not present you need to use the folder name and add the data to the excel

By using Your syntax You will not the Correct output because you dont know which folder is empty

cheers

what i want is to have the whole folder hierarchy with what they contain but even when the folder is empty i want it to be written in excel, you know how to do it?

@Soudios

yes i can provide you the solution like you are saying even subfolder is empty you want that to be in excel.

But what is the format you are expecting in the excel like

“C:\Users\cogni\OneDrive\Documents\UiPath” it is the main folder path ,Your are expecting like below

“c”,“User”,“Cogni”,“onedrive”,“Documents”,“UiPath”