Hi.
I want to find file like this
“c:\user\documents\2023-05-06_filename*.xls”
-I have to assign today’s date like that form (2023-05-06)
and, among that files, I have to find latest revised file.
Please help me
Hi.
I want to find file like this
“c:\user\documents\2023-05-06_filename*.xls”
-I have to assign today’s date like that form (2023-05-06)
and, among that files, I have to find latest revised file.
Please help me
@hoseongwon Hi, You want to get file with specific word and current date. right?
@hoseongwon
Try this one.
So while you are converting Type Argument as object for ForEach Activity then do as below :-
item.ToString.Contains(DateTime.Now.ToString(“yyyy-MM-dd”))
I forget to mention above der only
Mark as solution and like it if this helps you
Happy Automation
Please try this
Directory.GetFiles("FolderPath",Now.ToString("yyyy-MM-dd") + "*.xls").OrderByDescending(function(x) new fileinfo(x).LastWriteTime)(0)
Cheers
Hi @hoseongwon
Try this-
Use the Assign activity to create a string variable to hold today’s date in the desired format:
Assign todayDate = DateTime.Now.ToString(“yyyy-MM-dd”)
Use the Directory.GetFiles method to get all files matching the specified pattern:-
Assign filesArray = Directory.GetFiles("c:\user\documents", todayDate + “_filename*.xls”)
3.Use a For Each activity to loop through the filesArray and Inside the loop, use the Path.GetLastWriteTime method to get the last write time of each file:-
For Each file in filesArray
lastWriteTime = File.GetLastWriteTime(file)
If lastWriteTime > previousWriteTime
Assign previousWriteTime = lastWriteTime
Assign latestRevisedFile = file
Thanks!!
Thank you so much
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.