I'm going to assume by "latest" you mean "most recently modified file."
There is a C run time library function _fstat and _fstati64 (for large files > 4GB). The function signature for _fstat is:
int _fstat(int file_handle, struct _stat *file_info);
The _stat structure has a bit of useful information about the file, but you likely want the st_mtime
member, which has the last modified time as a time_t
(time in seconds since 00:00:00 UTC, January 1, 1970).
It may work to use the win32 functions FindFirstFile() and FindNextFile() to walk the directory, store the files in an array of a structure (containing the file name modified time) and then call qsort_s() on the array, sorting by time, in descending order.
I hope that helps.