得到FTP服务器上的文件的创建时间,修改时间
(用于文件比较,)

解决方案 »

  1.   

    /// 显示文件的最后修改时间
    /// @param[in] strPath 文件的路径名
    /// @param[out] strModificationTime 返回文件的最后修改时间
    int CFTPClient::FileModificationTime(const tstring& strPath, tstring& strModificationTime) const
    {
       strModificationTime.erase();   CReply Reply;
       if( !SendCommand(_T("MDTM ")+strPath, Reply) )
          return FTP_ERROR;   if( Reply.Value().length()>=18 )
       {
          tstring strTemp(Reply.Value().substr(4));
          size_t iPos=strTemp.find(_T('.'));
          if( iPos>-1 )
             strTemp = strTemp.substr(0, iPos);
          if( strTemp.length()==14 )
             strModificationTime=strTemp;
       }   if( strModificationTime.empty() )
          return FTP_ERROR;   return SimpleErrorCheck(Reply);
    }/// 显示文件的最后修改时间
    /// @param[in] strPath 文件的路径名
    /// @param[out] tmModificationTime 返回文件的最后修改时间
    int CFTPClient::FileModificationTime(const tstring& strPath, tm& tmModificationTime) const
    {
       tstring strTemp;
       const int iRet = FileModificationTime(strPath, strTemp);   memset(&tmModificationTime, 0, sizeof(tmModificationTime));
       if( iRet==FTP_OK )
       {
          tmModificationTime.tm_year = CCnv::TStringToLong(strTemp.substr(0, 4).c_str());
          tmModificationTime.tm_mon  = CCnv::TStringToLong(strTemp.substr(4, 2).c_str());
          tmModificationTime.tm_mday = CCnv::TStringToLong(strTemp.substr(6, 2).c_str());
          tmModificationTime.tm_hour = CCnv::TStringToLong(strTemp.substr(8, 2).c_str());
          tmModificationTime.tm_min  = CCnv::TStringToLong(strTemp.substr(10, 2).c_str());
          tmModificationTime.tm_sec  = CCnv::TStringToLong(strTemp.substr(12).c_str());
       }
       return iRet;
    }
      

  2.   

    多谢你的方法,如何得到CFTPClient,
    在线急等,
      

  3.   

    取时间,有API函数和MFC类也可以,我这个是封装了FTP协议的类,通过发送MDTM命令得到.
      

  4.   

    你的QQ号是多少,加你详谈,我的是qq=524875450,能不能发给我呀
    在线急等呀,我手头现在也没有什么资料,急!!!!