Checking a files creation date??

This is a discussion on Checking a files creation date?? within the C++ Programming forums, part of the General Programming Boards category; Hey everyone, I just started learning c++ a couple of weeks ago for a specific project so im not completely ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    2

    Checking a files creation date??

    Hey everyone,

    I just started learning c++ a couple of weeks ago for a specific project so im not completely confident with it.

    The program is currently being created in c++builder but will eventually be run in Linux. It allows the user to select a number of files (.txt files) from a dialog box, the file locations are then stored in an array and displayed in a listbox.

    I need to check what date all the files (selected by the user) were created on. I was wondering if anyone could help me out with how to do this?

    thanks.

  2. #2
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187

    Re: Checking a files creation date??

    >> will eventually be run in Linux.

    $ man 2 stat (to get file status)
    and
    $ man 2 utime (to change file time)
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    2
    thats Jaguar but i'm looking for a c++ function or something similar to check the file creation dates for me.
    Can you help me out with that at all?

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    9
    There is no "one-set-function" to return a file creation date, as far as I'm aware. In fact, I'm not certain if you can even determine a file creation date.

    Your "closest" option would probably be the file change date, as that requires more than content change to be updated; file attributes need to be modified.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    Well in Linux / Unix / any POSIX operating system, use stat() as mentioned already

    If you want a win32 function, use
    Code:
    BOOL GetFileTime(
      HANDLE hFile,
      LPFILETIME lpCreationTime,
      LPFILETIME lpLastAccessTime,
      LPFILETIME lpLastWriteTime
    );
    > but i'm looking for a c++ function
    No such thing - functions don't care what language they're written in, or what language the caller is written in.
    C++ is about classes and encapsulation of data - when it gets down to the gritty detail of actually getting some work done, it's all about functions.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. manipulate date on files
    By cnchybrid in forum C Programming
    Replies: 7
    Last Post: 04-19-2007, 12:54 AM
  4. CDate Class - handle date manipulation simply
    By LuckY in forum C++ Programming
    Replies: 5
    Last Post: 07-16-2003, 08:35 AM
  5. Help on File Creation with Date...
    By mehuldoshi in forum C Programming
    Replies: 2
    Last Post: 07-29-2002, 01:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21