Read Text File ,File Name + Dynamic Date

Hi Team,

I want to read text file,and path of text file is File Name+any date,if path of file name matches consider that as file .
Example as below:
***AGENT_DETAILS_***20190914.txt

If it matches AGENT_DETAILS_,then consider this is path of file.

Team,can any one can help here
Tried with above code,still getting error in Read Text File activity

When you are using the Directory.getfiles you will list of .txt files available in that folder once you got that you for each to loop all and then check the condition in that .txt file contains AGENT_DETAILS this or if yes then read.

1 Like

@RajeshT

Do you mean you want to read all text files from particular folder whose name starts with AGENT_DETAILS_ right ?

If yes then try below expression.

  txtFiles [] = Directory.GetFiles("FolderPath","AGENT_DETAILS_*")

Hi @lakshman,

Yes, I want to read text file from particular folder name starts with AGENT_DETAILS_
May i know which variable type we need to give for txtFiles

@RajeshT

It should be of type Array of string

1 Like

I have changed to array of string ,and Read Text File only allows string how we need to convert string of array to string

Hi @lakshman ,

Please help here this will be my last step to read text file

@RajeshT

After that assign activity, you have to use ForEach loop to iterate that array if string and inside this loop use Read Text file activity.

         ForEach item in txtFiles
             Pass item to Read Text file activity
1 Like

Hi @lakshman ,

I hope this is correct

@RajeshT

In Read Text file activity, just specify item only and no need to convert it to string.

Change Type argument from object to string in ForEach loop activity properties.

1 Like

Thank you @lakshman. Made the changes !

1 Like

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