Results 1 to 7 of 7

Thread: Archiving Tool & Preserving Dates...

  1. #1
    amac
    Guest

    Archiving Tool & Preserving Dates...

    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?

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Megatron
    Guest
    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 */

  4. #4
    amac
    Guest
    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...

  5. #5
    Megatron
    Guest
    Use SetFileTime.

  6. #6
    amac
    Guest
    haha... seriously?

    I figued it would be a lot more difficult than just calling a single function...

    Either way... Thank You.

  7. #7
    Megatron
    Guest
    No problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width