Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. To change the last-modified time of a file?

To change the last-modified time of a file?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Monisankar
    wrote on last edited by
    #1

    I want to change the modified time of a file by giving year,month..etc as input.To use SetFileTime() we need ptr to FILETIME structure.I am able to change the modified time to the current time by taking the systemtime.But facing problem to change to other input time.Please help...Thanks.

    D RaviBeeR 2 Replies Last reply
    0
    • M Monisankar

      I want to change the modified time of a file by giving year,month..etc as input.To use SetFileTime() we need ptr to FILETIME structure.I am able to change the modified time to the current time by taking the systemtime.But facing problem to change to other input time.Please help...Thanks.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Monisankar wrote: I want to change the modified time of a file...I am able to change the modified time So what is it that you are having troubles with? Perhaps a code snippet of what you are doing, and the results it is producing, is in order.


      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      1 Reply Last reply
      0
      • M Monisankar

        I want to change the modified time of a file by giving year,month..etc as input.To use SetFileTime() we need ptr to FILETIME structure.I am able to change the modified time to the current time by taking the systemtime.But facing problem to change to other input time.Please help...Thanks.

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        // Set system time to 31-Jan-1959 5:30am
        SYSTEMTIME st;
        ZeroMemory (&st, sizeof (st));
        st.wYear = 1959;
        st.wMonth = 1;
        st.wDay = 31;
        st.wHour = 5;
        st.wMinute = 30;

        // Convert the system time to a file time
        FILETIME ft;
        VERIFY (SystemTimeToFileTime (&st, &ft));

        // Set the file's modification time
        VERIFY (SetFileTime (hFile, NULL, NULL, &ft));

        /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups