Read multiple files from a directory

I have a folder with several files inside it.
I need to open these files to get some information that is inside those files.
What activity should I use to get the list of files within that folder?

Hai @tainan.ramos

files [] = Directory.GetFiles("FolderPath",searchOption.AllDirectories)

Then use ForEach loop to iterate all files.

1 Like

I put this structure inside an assign?
If so, what type of variable will receive the information?

@tainan.ramos… create variable file and pass it as array in assign activity … Feed like given above…

@Nandhuba
I appreciate the help, but I still can’t get it to work.
Here is a printout of the error.

The parameters you passed to the method are wrong.
Directory.GetFiles(,, )

where

  • FilePath =>Full Path of the folder (ex: “D:\RPA\ThisFolder”)
  • SearchPattern => Leave empty if no pattern is required. other wise, specify as string. (Ex: to retrieve pdf files alone, “*.pdf”)
  • SearchOption => Directory Search Options (ex: To search folder and all sub folders, SearchOption.AllDirectories)

In your case, you have specified “FolderPath” which is not a full path to any folder.
Search option is specified as second parameter, where the SearchPattern is expected

1 Like

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