I need to reset file creation and read it immediately. I have written the code as shown below

if (SetFileTime(hfile, &fts, (LPFILETIME) NULL, (LPFILETIME) NULL))
FlushFileBuffers (hfile);
if (GetFileTime(hfile,&ftg, (LPFILETIME) NULL, (LPFILETIME) NULL))

Now both this fts and ftg should be same. MSDN is giving remarks saying that across all file systems behavior may not be the same.

Please help in creating this code which should work from windows 98 to windows vista.

Re: Visual C++ General Using GetFileTime and SetFileTime

Marius Bancila

There are limitations of the file systems. You can't get across that.

Not all file systems can record creation and last access times and not all file systems record them in the same manner. For example, on FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). Therefore, the GetFileTime function may not return the same file time information set using SetFileTime. NTFS delays updates to the last access time for a file by up to one hour after the last access.