Hi folks - definitely a newbie here, so I apologize in advance.
I’m able to navigate to a folder where there are 2 files:
2020 Catalog (Effective 1_10_2020).xlsx
2020 Catalog (Effective 1_1_2020).xlsx
I need to get the most current file, and then copy it to a new location. I’ve toyed with using the creation date of the file, but am advised the surest way to get the correct file is to loop through the files in this directory, parse out the dates as as string, then convert to date. Then sort them to get the latest file and copy.
I’m just really stuck trying to figure this out.
Hi
kindly try with this expression for getting the latest writteen file from the folder
str_filepath = Directory.GetFiles(“yourfolder_path”,“*.xlsx”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0).ToString
Cheers @mark_newman
1 Like
Thank you! I’m being advised NOT to use CreationTime, but I’m starting to think it will work fine.
Appreciate the quick reply!
Mark
Absolutely love this solution !
I was trying to move the most recent downloaded file from my downloads folder and this worked like a dream … thank you @Palaniyappan
2 Likes
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.