Move a latest file from download folder with complete dynamic name

Hi guys! I am trying to move a freshly downloaded file from the download folder. However, the Excel file has a complete dynamic name. The good thing is that I only downloads one file so the file will always be at the top of the download folder. May I know how do I write my Move File activity so that I can get the file into another location? Thanks!

Hi @Hou_Paang_Soul
Try this

sortedFiles = fileArray.OrderByDescending(Function(f) New FileInfo(f).CreationTime).ToArray()
latestFilePath = sortedFiles(0)

or use

Hi! for the second method, what should I put into the from section? is it Currentfile? Thanks!


In From section give

In To section give the folder location where you want to save the file

Hi @Hou_Paang_Soul

You can get the file by using this expression since you know the type of file:
str_filepath = Directory.GetFiles(folder_path,“*.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)

Later you can give the str_filepath variable in move file activity.

Hope it helps.

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