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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Datestamp

Status
Not open for further replies.

BobLoblaws

Programmer
Nov 20, 2001
149
CA
I have a W32 console app, and I need to get the Created and Modified datestamps of a file (C:\Temp\Test.txt).
I have no idea how to get it, and any help is greatly appreciated.
 
you got to use the "WIN32_FIND_DATA" structure;

#include<windows.h>
.....
...
WIN32_FIND_DATA file;
HANDLE hFile;
if (( hFile = FindFirstFile( &quot;C:\\Temp\\Test.txt&quot;,&file ))
== INVALID_HANDLE_VALUE )
{
cout<<&quot;Invalid File Handle.&quot;<<endl;
exit(0);
}
DWORD t_created; // time when the file was created in nanoseconds
DWORD t_modified; // the last time it was modified in nanoseconds
t_created = file.ftCreationTime.dwLowDateTime;
t_modified = file.ftLastWriteTime.dwLowDateTime;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top