How to get a date and time of file creation



  • I created a list of files:
    static QStringList files;
    declared variable, which will put the date in a different format
    static QString fileCreatedAt = NULL;

    in one branch of CASE prescribed the following code:

    static QFileInfo InfoAboutCurrentFile (files.at (i));
    fileCreatedAt = InfoAboutCurrentFile.created (). ToString ();

    an error of type QDateTime.

    invalid use of incomplete type Struct QDateTime

    Tell me how you can get creation date of files in a loop in the thread and even CASE (correctly declare the constructor for information on the following file?) format datetime and unixtimestamp?



  • You most probably forgot to include the corresponding header, <code>#include <QtCore/QDateTime></code>.

    In addition, it is <code>.toString()</code>, not <code>.ToString()</code>. Is there any particular reason all your variables are <code>static</code>?



  • Since "created()":http://doc.qt.nokia.com/4.7-snapshot/qfileinfo.html#created returns a QDateTime you need the definition of that class, so have you tried #include <QDateTime>?



  • connected headers and working! The next time I'll be careful with connecting headers. I thought the creation date and that was: I got the date the file was created on my disk. But originally it was created in a different place and date of creation it is different. Can tell me how to read the original creation date of a file?



  • Qt passes the information it retrieves from the operating system and the file system. You will have to make sure that the timestamps are preserved when the files are copied to your disk - otherwise the information is lost.



  • Well, maybe when you have files like a picture that includes information inside it you are able to get the production date, type of camera model etc. The QFileInfo just gives back the information of the file itself, so when copied the original date may be lost.
    Greetz


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.