I am downloading 2 files one by one how to get the name of the files as i need to move both files in different folder

i am downloading 2 files one by one how to get the name of the files as i need to move both files in different folder

@manoj2500 After you have downloaded the two files, You can first get the downloaded File names by using this Expression :
Directory.GetFiles(yourFilePathVar).OrderByDescending(Function(x)new System.IO.FileInfo(x).CreatedDate).ToArray

Assign the above Expression to an Array of String variable, say fileNames.

To get the Latest Two Downloaded files, you can use this :
fileNames(0) to get the Second downloaded file.
fileNames(1) to get the First Downloaded file.

Try this and let me know.

3 Likes

I am getting complier error
Directory.GetFiles(“C:\Users\arpan.bangera\Downloads”).OrderByDescending(Function(x)new System.IO.FileInfo(x).CreatedDate).ToArray

when i am assigning this value to variable

@manoj2500 What is the Error and make sure you have used your Download Path :sweat_smile:

yes have provided the download folder path

1 Like

@manoj2500 What is the Error you get?

@supermanPunch!

i am getting this errorUntitled1

@supermanPunch i am getting this errorUntitled1

hey its working thanks

i want to make sure that the file downloaded today so it should get today file but as per you file that is getting selected is last file in the folder

1 Like

@manoj2500 If you want to get the files which are downloaded to day you can use this :

Directory.GetFiles(yourFolderPath).OrderByDescending(Function(x)Split(new System.IO.FileInfo(x).CreatedDate)(0).Equals(Now.ToString(“MM/dd/yyyy”))).ToArray

Check this and See if it Works

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