Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to clear OS Disk Cache? 1

Status
Not open for further replies.

dwunz

Programmer
May 4, 2001
28
0
0
US
We have a program that keeps log files for the month...the following month, we just want to remove the old file for that day and create a new one. Problem is...when we delete the old one and create the new one (with the same name) the new file has the same creation date/time the old file had. A look through Help on CreateFile tells us "Windows NT/2000 or later: If you rename or delete a file, then restore it shortly thereafter, Windows NT searches the cache for file information to restore. Cached information includes its short/long name pair and creation time." Can anyone give us a hint about how to get the proper create time on the files?
 
1. create file1
2. remove old ini file
3. rename file1 to old ini file Ion Filipski
1c.bmp


filipski@excite.com
 
That made sense to me, too. We tried that...the creation date is still recovered from cache. The new file gets a current create date, but, after removing the old file and renaming the new one, it gets the creation date from the old file.
 
does this file persist in RecycleBin after deleting? Ion Filipski
1c.bmp


filipski@excite.com
 
We're using the API call DeleteFile to delete the file...and, no, the file does not show up in the Recycle Bin. We also tried changing the order to Delete, Create with new name, then rename...same result.
 
By the way, the SetFileTime function sets the date and time that a file was created, last accessed, or last modified.
BOOL x SetFileTime(hFile,lpCreationTime,lpLastAccessTime,lpLastWriteTime);
where the last three arguments are pointers to FILETIME structure.
Ion Filipski
1c.bmp


filipski@excite.com
 
Ok...that doesn't answer why we're getting this peculiar result with the system, but using SetFileTime should let us get around the problem we are having. Don't know how we missed that (I looked...really I did...). Thank you. Hopefully, this thread is dead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top