2.1.8.17 get_file_time


Description

Get file last write time and create time as Julian date value or as string.

Syntax

BOOL get_file_time( LPCSTR lpcszFile, double * pdLastWriteTimeJulian = NULL, double * pdCreationTimeJulian = NULL, LPSTR pszLastWriteYMDHMS = NULL, LPSTR pszCreationYMDHMS = NULL )

Parameters

lpcszFile
[input] file's full path.
pdLastWriteTimeJulian
[output] pointer to file last write time as Julian date value. default is NULL.
pdCreationTimeJulian
[output] pointer to file create time as Julian date value. default is NULL.
pszLastWriteYMDHMS
[output] pointer to file last write time as string like YY-MM-DDTHH:MM:SS. default is NULL.
pszCreationYMDHMS
[output] pointer to file create time as string like YY-MM-DDTHH:MM:SS. default is NULL.

Return

TRUE if Success, otherwise FALSE.

Examples

EX1

//the file test.txt must exist in temp folder path
void get_file_time_Ex1()
{
    char szTemp[MAXFULLPATH];
    GetTempPath(MAXFULLPATH, szTemp); // Get temp folder path.
    string strFile = szTemp + "\\test.txt";
    double dLastWriteTime, dCreationTime;
    bool bFlag = get_file_time(strFile, &dLastWriteTime, &dCreationTime);
    if(!bFlag)
        printf("failed to get file's last write time");
    else 
    {
     out_str("the file's last write time is "+get_date_str(dLastWriteTime, LDF_SHORT_AND_HHMM_SEPARCOLON));
     out_str("the file's creation time is "+get_date_str(dCreationTime, LDF_SHORT_AND_HHMM_SEPARCOLON));
    }
}

Remark

See Also

GetTempPath, get_date_str

Header to Include

origin.h

Reference