Hi
I’m reading a file with read activity whose file name changes every time when it downloads
like 1st time file name downloaded with name “response…12345…html”,
2nd time with name “response…4567…html”, etc first part is same that is “response” but remaining number varies every time… how to read this variable?
Hi @Aima_Arif,
If you want to get the files from the folder you can use
Assign activity as Stringarray variable = Directory.GetFiles(YourFolderPath)
So using for each activity you can loop into the String array and split the file name
Hope this may help you
Thanks,
Srini
I’m not reading from the folder
It downloads the link with above file names and then i have to read that file
The file name changes every time when it downloads
Is your bot downloading the file? If yes, you can use the Wait for Download activity. It will return the filename of the downloaded file in a variable you specify.
Hi @Aima_Arif
str_filepath = Directory.GetFiles(yourfolder_path,“*.pdf”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList()(0)
Hope this might help you
It gives index out of range exception for some files
Could you please share your screenshot?
in assign activity error comes
Index was out of range. Must be non negative and less than the size of collection
Hi @Aima_Arif
Check folder has any files or not. if the file is not present in the particular folder above error will throw.
folder has downloaded file present there
ArrayOfString = Directory.GetFiles("FolderPath"."response*").OrderByDescending(function(x) File.LastModifiedTime(x)).ToArray()
This will give you all files with response as the starting of the name
And now first check if there are any values returned using ArrayOFString.Count >0
If yes then use ArrayOfString(0)
to get the first file
ArrayOfString is avariable you need to create of type array of string
Hope this helps
cheers
Hi @Aima_Arif Since the downloaded folder has the files you can use the below exp
Output var of type Array of Strings = Directory.Getfiles("FolderPath","*.yourfileextension")
Now use For Each
to read the each file
This exp reads the files present in that folder irrespective of the file names
this helped
thank you so much:)
Thank you
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.