Hi,
i was jut asked by a freind, Could you write a program that changes the Times-Stamp of a File?
E.g. Change the Time of Creation, the Time of Lastmodified and Lastaccessed?
So, my answer was Yes, sure.
But, changing the Timestamp for a singel file works perfectly as I thought. Changing the Timestamp for multiple Files (in a findfile...findnext Construction) fails.
Why?
sysTime predefined;
hFind = FindFirstFile("D:\\Temp57\\*.*", &fd);
while (hFind != INVALID_HANDLE_VALUE && bRet)
{
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
{
SystemTimeToFileTime(&sysTime, &fLocTime);
LocalFileTimeToFileTime(&fLocTime, &fTime);
hFile = CreateFile(fd.cFileName, GENERIC_READ | GENERIC_WRITE, 0 ,NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING, NULL);
SetFileTime(hFile, &fTime, &fTime, &fTime);
CloseHandle(hFile);
}
bRet = FindNextFile(hFind, &fd);
}
FindClose(hFind);
break;
Any Idea is welcome.