I need to compare a file's last modified time to a date time stored in a database. I initially looked at this question to get started.
I am currently getting the FILETIME
for the last write of the file, converting it to a SYSTEMTIME
. Then I use that SYSTEMTIME
to create a TDateTime
object that I can use for my comparison. However, the FileModifiedDT
variable, is always coming out to be the current time, despite the file having been modified previously.
FILETIME lastWriteTime;
String * FileNamePtr = new String( FileName );
GetFileTime( FileNamePtr, NULL, NULL, &lastWriteTime );
SYSTEMTIME systemTime;
FileTimeToSystemTime( &lastWriteTime, &systemTime );
TDateTime * FileModifiedDT = new TDateTime( systemTime.wYear, systemTime.wMonth,
systemTime.wDay, systemTime.wHour,
systemTime.wMinute, systemTime.wSecond,
systemTime.wMilliseconds );
Am I missusing GetFileTime
in some way? Is there a better way I should go about this?