1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Windows file manipulation with C

Discussion in 'C' started by Ravi Mahadevan, Jan 5, 2011.

  1. Ravi Mahadevan

    Ravi Mahadevan New Member

    Joined:
    Jan 5, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    In Windows 2003 when application modifies a binary file - size of the file and last time modified have not been affected because the file was created as a fixed size file. But my application need to find out based on some file attribute whether file content is changed or not since last access. Can you please suggest a api or system call to be used in windows "C" programming to achieve this?. At present "GetFileTime" and "GetFileSize" APIs are being used but that does not dectect when the file is modified.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    You could keep a copy of the file and do a byte-by-byte check.
    Or you could calculate the MD5 of the file's content and store that.

    Either method will show up any difference in the file content.
     
    Ravi Mahadevan likes this.
  3. Ravi Mahadevan

    Ravi Mahadevan New Member

    Joined:
    Jan 5, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Thank you for your inputs.

    You could keep a copy of the file and do a byte-by-byte check - I guess, this would really consume lots of time since the application file size is very huge I would not go for it

    Or you could calculate the MD5 of the file's content and store that. - Seems to be a good idea. Let me try this
     

Share This Page