Reputation: 19
How to preserve old timestamp after i change it ? i need to do this in win32 api
hfile = CreateFileA(path, //stackoverflow wont allow me submit this unless i include source ugghh >_<
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);
Upvotes: 0
Views: 226
Reputation: 37132
You can call SetFileTime
on the file handle like so:
FILETIME ft = { MAXDWORD, MAXDWORD };
SetFileTime(hFile, NULL, &ft, &ft);
This stops the system from modifying the timestamps when the file is written to.
Upvotes: 3
Reputation: 31394
You can do so by calling GetFileTime
before you write the file and and SetFileTime
with the original times to restore the file's previous timestamps.
Upvotes: 2