Pick files

i have folder where i am saving file in date format 24-Apr-22 what i want to do is i want to pick the oldest file as per date i.e if we have file date 24-feb-22 and then 25-feb-22 then i should pic 24feb file then 25feb file

*folder may have lot of files 20 or 30


Can you try the following?

files = System.IO.Directory.GetFiles(yourPath)

oldest = files.Where(Function(f) System.Text.RegularExpressions.Regex.IsMatch(System.IO.Path.GetFileNameWithoutExtension(f),"\d{1,2}-[A-Za-z]{3}-\d\d")).OrderBy(Function(f) DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(System.IO.Path.GetFileNameWithoutExtension(f),"\d{1,2}-[A-Za-z]{3}-\d\d").Value,"d-MMM-yy",System.Globalization.CultureInfo.InvariantCulture)).First