I am writing an Archiving tool, and I want to preserve the Created and Modified Dates, but not sure how to do it.
I don't really care so much about the Created date, but the modified date needs to be the same.
Any ideas?
Printable View
I am writing an Archiving tool, and I want to preserve the Created and Modified Dates, but not sure how to do it.
I don't really care so much about the Created date, but the modified date needs to be the same.
Any ideas?
Look at GetFileInformationByHandle. This makes it easy to get the created and last modified times. Writing them is going to be a lot more complicated...
It's just a simple matter of converting a FileTime structure to a SystemTime structure e.g
Code:FILETIME lpmod;
SYSTEMTIME st;
LPSTR lpTime;
HANDLE hFile = CreateFile( "MyFile", GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile )
{
GetFileTime(hFile, NULL,NULL,&lpmod);
FileTimeToSystemTime( &lpmod, &st );
wsprintf( lpTime, "%d/%d/%d %d:%d:%d",
st.wMonth, st.wDay, st.wYear, st.wHour, st.wMinute, st.wSecond );
CloseHandle(hFile);
}
MessageBox( hWnd, lpTime, NULL, NULL );
/* lpTime contains the date in the format m/dd/yyyy hh:mm:ss */
K, cool...
Alright, so I place a file into the archive and store its modified date. What about when I extract the file from the arhive? How can I return the modified date to its original value?
I'm open for any suggestions here....
I took a look at Winzip and it seems to preserve the Modified Date, but the Created Date becomes equal to the Modified Date...
Use SetFileTime.
haha... seriously?
I figued it would be a lot more difficult than just calling a single function...
Either way... Thank You.
No problem :)