How can I determine a file's creation date in Windows?

后端 未结 4 1844
一个人的身影
一个人的身影 2021-01-13 02:08

How can I get the date of when a file was created? I am running Windows.

相关标签:
4条回答
  • 2021-01-13 02:50

    For C, it depends on which operating system you are coding for. Files are a system dependent concept.

    If you're system has it, you can go with the stat() (and friends) function: http://pubs.opengroup.org/onlinepubs/009695399/functions/stat.html.

    On Windows you may use the GetFileTime() function: http://msdn.microsoft.com/en-us/library/ms724320%28v=vs.85%29.aspx.

    0 讨论(0)
  • 2021-01-13 02:56

    Unix systems don't store the time of file creation. Unix systems do store the last time the file was read (if atime is turned on for that specific file system; sometimes it is disabled for speed), the last time the file was modified (mtime), and the last time the file's metadata changed (ctime).

    See the stat(2) manpage for details on using it.

    0 讨论(0)
  • 2021-01-13 02:57

    Use stat function

    see here

    #include <sys/stat.h>
    
    #include <unistd.h>
    
    #include <time.h>
    
    
    
    struct tm* clock;               // create a time structure
    
    struct stat attrib;         // create a file attribute structure
    
    stat("afile.txt", &attrib);     // get the attributes of afile.txt
    
    clock = gmtime(&(attrib.st_mtime)); // Get the last modified time and put it into the time structure
    
    0 讨论(0)
  • 2021-01-13 03:06

    On Windows, you should use the GetFileAttributesEx function for that.

    0 讨论(0)
提交回复
热议问题