I have a path on which files will be dumped randomly on any day. I have a service which will be running daily to check if we have any latest file dumped. File name will be as "AMCR_Handoff_Report_21022021.txt". Date will be mentioned in the file name.
Now I need to fetch the latest file checking the date modified column.
I have this piece of code which gives me all the files along with directory, and then I need to check all the files based on the date part which doesn't makes sense. There should be an easier way to achieve this I guess.
string[] files = System.IO.Directory.GetFiles(amcrNDMPathWithFileName, "AMCAR_Handoff_Report_*", System.IO.SearchOption.TopDirectoryOnly);