Read All File From Sub Folder and sub folder of sub folder

Hello
I want to read all files from sub folder and Sub folder of sub folder.
you Can Check screenshot

Thank you
Read File

Hey Vishal,

you can try to first get all of your sub folders inside the Main Folder by using Directory.GetDirectories(MainDirectory,“.”,SearchOption.AllDirectories) and assigning it to an array variable. Then, inside for each loop, you can use another useful expression Directory.GetFiles(File).

This should let you have all of the neccessary files, so you can iterate through and read them.

Let me know if you have any questions :slight_smile:

1 Like

Hello @Vishal_Prajapati

You can refer to the below post.

You can just get all the files that way.

Directory.GetFiles(MainDirectory,“*.*”,SearchOption.AllDirectories)

No need to do it in two steps.

3 Likes

You are right, Paul. Thanks for sharing this :smiley:

I don’t want to read all files at time.
I want read file subfolder wise and save details in Excel sheet subfolder wise

Hi Bro.

How many subfolder in SubFolder1, SubFolder2…etc

One folder in subfolder 1

What kind of the excel sheet you want to write the output ?

Please check attached image
readFile

Just like it

Get some details in pdf file

you should itereate through the for each folder

each folder name will be your column 1 values and use Directory.GetFiles(MainDirectory,“.”,SearchOption.AllDirectories) for get all subdirectory files

Thank you for your help.
I have use ‘For each folder in folder’ activity

You can read all the files in one go, and then loop through them using Get File Info to get the path and all other details to store in your spreadsheet.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.