Datum vom File abfragen



  • Hallo Leute,

    kann mir jemand Helfen ??

    Ich möchte das Datum oder Zeit von einem File heraus bekommen.

    Ich habe bislang die Funktion GetFileTime gefunden.
    Ich komme allerdings nicht mer weiter.

    Hier meine Funktion mit der ich das Datum erfragen möchte.

    meine Funktion:

    string filedatum(string u_file)
    {
    ifstream inputfile;
    string dasDatum;
    FILETIME ftAccess;

    inputfile.open(u_file.c_str());
    dasDatum = GetFileTime(inputfile, NULL, ftAccess, NULL);
    return dasDatum;
    }

    Bitte nicht auslachen, was besseres bringe ich momentan nicht hin

    Man muß mit Handle arbeiten, das kenne ich aber nicht.

    Gruß
    andy_mann



  • Das ist WinAPI, gehoert nicht zu Standard C++.

    BOOL GetFileTime(
    HANDLE hFile, // handle to the file
    LPFILETIME lpCreationTime, // address of creation time
    LPFILETIME lpLastAccessTime, // address of last access time
    LPFILETIME lpLastWriteTime // address of last write time
    );

    Die Funktion gibt einen bool zurueck. Deine Variable "dasDatum" muss also bool sein, nicht string!

    Das Datei-Handle bekommst du mit FindFirstFile.

    HANDLE FindFirstFile(
    LPCTSTR lpFileName, // pointer to name of file to search for
    LPWIN32_FIND_DATA lpFindFileData
    // pointer to returned information
    );

    Genauere Infos zu den Funktionen bekommst du hier:http://msdn.microsoft.com/

    Gruss Jochen


Anmelden zum Antworten