I want to extract the Date value for a specific file and compare it with Date Modified and Date Created, in Visual C++.
I've seen that I can extract Date Created and Date Modified, but I don't know anything about Date.
I've altered some files with a buggy software, and the only column that still has a valid time is the Date one. How can I extract it?
I'm using Windows 7 x64.
Here, I've seen only st_atime, st_ctime, st_mtime: http://msdn.microsoft.com/en-us/library/14h5k7ff.aspx
Windows stores three timestamps for each file or folder:
There are a number of ways to read these timestamps, but using the native Win32 API you can do the following:
LPCWSTR pszFileName = L"c:\\path\\to\\myfile.txt";
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(pszFileName, &wfd);
if (hFind != INVALID_HANDLE_VALUE)
{
FindClose(hFind);
// timestamps can now be found at:
// wfd.ftCreationTime
// wfd.ftLastAccessTime
// wfd.ftLastWriteTime
}
You can use functions like FileTimeToSystemTime()
to convert the FILETIME
values (which are simply a tick count since a specific date) into more usable SYSTEMTIME
structures which give you day, month, year, hour, minute, etc.
Note: "Last modification time" is also updated for folders, as well as files, and indicates the last time a file was modified directly inside that folder. Changes to folder timestamps are not propagated to parent folders.
Note 2: "Last access time" is more or less deprecated, and is disabled by default in newer versions of Windows. You can enable it using a registry setting.