C++ 获得指定路径文件的“修改日期”

    SYSTEMTIME time;     
    CString path;
    path=L"I:\testpicture\1.bmp";//文件路径
    CStdioFile file;
    file.Open(path,CFile::modeRead);
    FILETIME file_time;
    FILETIME locationtime;

    GetFileTime(file.m_hFile,NULL,NULL,&file_time);//获得文件修改时间
    FileTimeToLocalFileTime(&file_time,&locationtime);//将文件时间转换为本地文件时间
    FileTimeToSystemTime(&locationtime,&time);//将文件时间转换为本地系统时间
    CString strTime;
    strTime.Format(L"%4d%2d%2d",time.wYear,time.wMonth,time.wDay);//利用CString的格式化语句格式化时间数据
    MessageBox(strTime);
    file.Close();



  

   

原文地址:https://www.cnblogs.com/weixinhum/p/3916711.html