Read a file whose name is the date from the array

Hello! Help me please. I have an Array of strings, each string is a date. For example {date.now.tostring (“yyyyMMdd”), now.adddays (-1) .tostring (“yyyyMMdd”}. Also in the folder on the C drive there are files with dates in their names. For example, files АBC_20201005.docx, АBC_20201004.docx, ABC_20200913.docx, АBC_20200915.docx. I need to read files one by one in the name of which there is a date from the array. How can this be done?
Thank you for your answers!

Use a Foreach activity to loop through the array, eg. Foreach item in DatesArray
In the loop, construct the filename using Path.Combine(), eg. Filename = Path.Combine(“C:\YourFolder”, “ABC_” + item + “.docx”)
Verify that the file exist using an If activity with File.Exist() and then use the Word Read Text activity to read the file.

The above is under the assumption that all the filenames start with “ABC_”. If not, you need to do this instead:

Use Directory.GetFiles() to get a list of all filenames in the folder.
Use Foreach to loop through the file list array.
In the loop:
Extract the date part of the filename using substring or regular expression.
Use Contains() to verify if the date is in the array, eg. DatesArray.Contains(date)
If true, read the file.

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