Read files within folders and subfolders

Hello there everyone!

I need help to iterate through multiple subfolders and search for a given file by name.

I have a root folder (say "C:\TestFolder") and multiple subfolders within the root folder (say, "C:\TestFolder\Names", "C:\TestFolder\Dates", "C:\TestFolder\Adresses").

I can read the root folder with a for each activity and get the full path for each subfolder, but I can’t seem to get each of those items (complete path and name for each subfolder) and search within each of them for a file.

I have attached an image of the workflow below:

Could you please help me out! Thanks in advance!

1 Like

Maybe following can help:
Directory.GetDirectories(YourPath,“*”, SearchOption.AllDirectories)

1 Like

Thank you so much! That does let me iterate through all subfolders.

if we got the list of subfolders then how we will get the files from these subfolders and read it?


As Uipath forum best practices, it is preferred to open a new post if you have a second question.

To get the files, you use:




The below workflow will extract all the folders and files from the input path.

Workflow file
Main.xaml (7.9 KB)