Copying a latest downoaded csv file


I need to copy the data from latest csv file to excel, but when am trying it is throwing error as it not able to read the CSV.The only problem is am not read the latest downloaded file.

Can some help me on this.

to get the latest file from the folder
out_folderpath = Directory.GetFiles(yourfolder_path,"*.csv").OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1)

where out_folderpath is a string variable

–now pass this variable as input to read csv and get the output as datatable
–use that datatable as input to write range inside excel application scope

hope this would help you
Cheers @Karthik_Kulkarni

Hi Palaniyappan,
sorry to ask you

out_folderpath = Directory.GetFiles(yourfolder_path,"*.csv").OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1)

From the above yourfolder_path is what exactly ,here my csv file is in “C:\Users\1013592\Downloads”, so i gave as below is that correct.

out_folderpath = Directory.GetFiles(C:\Users\1013592\Downloads,"*.csv").OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1)

1 Like

yes exactly but a small correction a typo mistake
out_folderpath = Directory.GetFiles(C:\Users\1013592\Downloads,"*.csv").OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0)

Cheers @Karthik_Kulkarni

so were we able to open the latest one
cheers @Karthik_Kulkarni


I gave the below one but no luck.

Directory.GetFiles(C:\Users\123456\Downloads,"*.csv").OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0)

1 Like

do that folder has any csv file
kindly check that once
this would surely work
or lets do one thing
lets check whether this expression is fetching any value or not by checking the count
in write line mention this expression to check for the count being more than 1 or not
Directory.GetFiles(C:\Users\123456\Downloads,"*.csv").OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList().Count
Cheers @Karthik_Kulkarni


As of now assign activity havent throwed any error,but when am exceuting complete bot it is throwing error as illegal characters in path


Kindly check once with the path whether any special characters or space is used in between across the path
That’s the reason why this error is coming up
You were almost done

Cheers @Karthik_Kulkarni

In Actvity value i gave as

Directory.GetFiles(“c:\users\123456\downloads”"*.csv").OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0)

Comma missing between folder path and file extension
Directory.GetFiles(“c:\users\123456\downloads”,”*.csv").OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0)