Hi all, I need to go to a folder, sort the files by date modified and locate the current date file in the folder of type .txt. If the file is available then need to validate that file contains today’s date in format nameoffile_yyyymmdd.txt. Once we have validated the correct file then need to open it with notepad.
This will give your the expected file names as a List(Of FileInfo)
Directory.GetFiles("C:\Test", "*.*", SearchOption.AllDirectories).[Select](Function(f) New FileInfo(f)).Where(Function(f) (f.Name.Contains(DateTime.Now.Date.ToString("yyyyMMdd"))) And (f.Extension.Equals(".txt")) And ((DateTime.Now - f.LastWriteTime).Days=0)).ToList()