How to get the last downloaded xlsx file from the Folder

Hi guys, I created a workflow to copy the latest downloaded excel file from my download folder to the required destination. However, I’m getting an error when I used the workflow.

Workflow credit : ashley 11

str = String.Join(“”,Directory.GetFiles(Path,File_Type,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )


1 Like

Hi @dmitroika1

Change the Path to "C:\User\fred\Downloads"


Hi @dmitroika1
What error did you encounter ?

cheers :smiley:

Happy learning :smiley:

1 Like

Hi @dmitroika1

If i got it right what you want is to get the latest downloaded file in an spefic folder. When you use the method Directory.GetFiles, the first argument expected is the path of the spefic folder that you want get the files, what you are passing is the path of the file instead of path of the folder. Change the “Path” variable to “C:\User\fred\Downloads” as @wusiyangjia suggested and it should work.

Happy coding! =)

Thanks guys… it worked!!

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