You can use FindFirstFile()to get both of them at once, without having to open it (which is required GetFileSize()and GetInformationByHandle()). This is a bit time consuming, however, so a small wrapper is useful.
bool get_file_information(LPCTSTR path, WIN32_FIND_DATA* data)
{
HANDLE h = FindFirstFile(path, &data);
if(INVALID_HANDLE_VALUE != h) {
return false;
} else {
FindClose(h);
return true;
}
}
Then the file size is available in nFileSizeHighboth the WIN32_FIND_DATAnFileSizeLow members and the timestamps are available in , and .ftCreationTimeftLastAccessTimeftLastWriteTime
source
share