Hello Guys , I’m trying to get the most recent excel file in a specific folder .
i tried using the Method " Out_filepath = Directory.GetFiles(“yourFolderPath”,“*.xlsx”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) ) "in Excel Application Scope File path but it gave me error .
any advice ?
Hi @Abx9 ,
What is the error message you are getting.
Try with below expression and let us know. Thanks.
str_filepath = Directory.GetFiles(yourfolder_path,“*.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)
it gave an error the “str_filepath” is not declared and couldn’t reach because of security permition
Hi @Abx9 ,
Could you pls create variable str_filepath as string type.
With the above expression you will get latest xlsx file path into str_filepath
After that you could use this str_filepath in the excel application scope and try to open that file and let us know.
One more thing put this str_filepath in log message and see if you are getting latest excel file path. Thanks
Hi @Abx9
First create a directory variable with DirectoryInfo type ex directorylocation
directorylocation = new DirectoryInfo("your excel file directory")
Then you have to create a another array variable with FileInfo type. ex newly_created_files
newly_created_files = directorylocation.GetFiles(".xlsx").Where(function(file) file.LastWriteTime.Date=DateTime.Now.Date).OrderByDescending(function(d) d.LastWriteTimeUtc).ToArray
Today created files are stored in newly_created_files
Pass this array variable inside a for each activity incase if multiple excel files was created today
Or else
If you have single excel
Create a variable with Genericvalue Type ex MyExcelFile
MyexcelFile = newly_created_files(0).ToString
Hope it solves your issue
And update us whether you got your desired solution or not
Thanks
Robin
please find the attached xaml file for more reference
TodaysNewestFileIinDirectory.xaml (9.9 KB)
Thanks,
Robin
thanks for the help
Your welcome
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.