I have downloaded the latest Excel file that I am going to use via UiPath. Now I have to open this file, but since it is dynamic, and the latest Excel file today might not be the latest file tomorrow, I have to use some kind of function?
I have read that I have to write something like this in Excel application scope.
DirectoryInfo().GetDirectories(“*”,SearchOption.AllDirectories).OrderByDescending(function(d) d.CreationTime).First();
We can use like this Out_filepath = Directory.GetFiles(“yourFolderPath”,“*.xlsx”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )
Where out_filepath a variable of string which will get the last created file from the specified folder
Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @Karsten_Bertelsen
Does this mean that is have to insert this sentence in Excel Application Scope, while replacing “yourFolderPath”?
**Directory.GetFiles(“yourFolderPath”,“*.xlsx”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )
Yes we can directly mention this in the file path of excel application scope
And if so no need of creating variable out_filepath and it is actually as string variable storing the above expression. Result
Cheers @Karsten_Bertelsen
String.Join(“”,Directory.GetFiles(“YourFolderPath”,“*xls”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )