Issue in getting latest file from folder

Hi Team,


The robot is not using the latest downloaded file from the folder, it is using the previously downloaded file.
for example : Two files are downloaded one at 10:13 AM and another one at 10:18 AM
the bot should use the same excel which is downloaded at 10:18 AM , i.e. it should use the latest and current downloaded file
in my case , the bot is using the excel file which is downloaded at 10:13 AM.
Requesting anyone’s help over here. the below code i’m using
io_str_Filepath = Directory.GetFiles(folderpath,“Out Of *.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0)

Thanks in advance,
Naveen Kumar

Hi @naveenkumarr

Try with this expression

Directory.GetFiles(YourFolderPath,"*.xlsx").OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)

Regards
Gokul

1 Like

Hello @naveenkumarr ,

Please try to use the Wait for Download activity (link: https://docs.uipath.com/activities/docs/get-last-downloaded-file ) and used the Output ( Downloaded file)

Hope it helps!
Best regards,
Marius

1 Like

Check out this blog for more info @naveenkumarr

Regards
Gokul

1 Like

Hi @naveenkumarr try this LINQ

(
From f In New DirectoryInfo(filePath).GetFiles(“*.txt”).Cast(Of FileInfo)
Order By f.LastWriteTime Descending
Select f
).First()

1 Like

Hello Guys,

i just added delay after click save button, it is working .
Thanks everyone for the response.

Regards,
Naveen Kumar

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