Find latest File in a folder with respect to date Created

Thank you so much. I should have realised the same after getting a blank screen. :sweat_smile:
Could you please forward me the link where I can read more about the method used.

For anyone looking for a solution for the same problem, the final code is :slight_smile:

String.Join("",Directory.GetFiles("FolderPath","FileType/FIleNameSequence",SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )

where
FileType is the type of file you are looking for

Example:
You could be looking for latest excel file in the folder. so the File type should be replaced by “*.xlsx”

FIleNameSequence Is the naming Sequence of the file (in cases where file has fixed part and a variable part:

Let’s say there are many files in the folder and you are looking for txt files which are named as “XXXx_abc.txt” then the FIleNameSequence should be replaced by “*abc.txt”

NewestFileIinDirectoryAnyDay.xaml (6.6 KB)
TodaysNewestFileIinDirectory.xaml (10.7 KB)
LatestDirbyDateCreation.xaml (5.3 KB)

Thanks @Dominic and @vvaidya

12 Likes