I am a real newbie in C#, and I am trying to get the most recent modification time (LastWriteTime) for any file in a directory.
What is a simple way to get this information ?
>Solution :
I would simplify your code to use this approach:
DirectoryInfo di_source_directory = new DirectoryInfo(@"C:\MyFolder");
FileSystemInfo[] ls_fi = di_source_directory.GetFileSystemInfos();
DateTime ts_most_recent = (ls_fi.Any()
? ls_fi.Max(fi => fi.LastWriteTime)
: default(DateTime));
or just replace the default(DateTime) part with new DateTime(…..)