Probably you mean "most recent file". Most recently created or most recently written?
After you get all files in question in the form of the instance of
System.IO.FileInfo
, you can use
System.IO.CreationTime
or
System.IO.LastWriteTime
(depending on what time do you need) and compare time. Please see:
http://msdn.microsoft.com/en-us/library/system.io.fileinfo.aspx[
^].
Remember that the time resolution is not high, it's a millisecond. Please see:
http://social.msdn.microsoft.com/Forums/eu/csharpgeneral/thread/bed97747-923d-4078-9ae3-04e0b0192342[
^].
By the way, many are confused about how to compare the instances of
System.DateTime
. The answer is simple: use the operator "<" or ">". Please see:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[
^].
—SA