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();



  

   

posted @ 2014-04-12 15:59  weixinhum  阅读(1451)  评论(0编辑  收藏  举报