我是用ftpFind.GetLastWriteTime(ctime)的方式取的时间,但时间总是差一年,如用cuteftp看到文件日期是2004-11-25 14:16:00,我取到的时间确是2003-11-25 22:16:00年份差一年,小时也差8个小时,这是为什么呀?急死我了,帮帮忙呀!

解决方案 »

  1.   

    我看了GetLastWriteTime函数的msdn, 看看人家的提示
    Note Not all file systems use the same semantics to implement the time stamp returned by this function. This function may return the same value returned by other time stamp functions if the underlying file system or server does not support keeping the time attribute. See theWin32_Find_Data structure for information about time formats. On some operation systems, the returned time is in the time zone local to the machine were the file is located. See the Win32FileTimeToLocalFileTime API for more information.建议你用FileTimeToLocalFileTime函数将时间转换一下,试试
      

  2.   

    今天又发现新情况,if ( 本地机器系统时间 < (服务器上文件时间+8小时) )
    {
       用ftpFind.GetLastWriteTime取得此文件的最后修改时间和实际相差1年。
    }比如FTP服务器上一文件a.txt的时间是 2004-11-30 10:00(用cutftp看到)
    如果我本地机器的时间在2004-11-30 18:00之前的话,我取到的时间都是2003-11-30 10:00(相差一年)我还发现用ie去看此文件信息存在相同的情况,我怀疑是微软的BUG。我想应该是有办法解决的,因为用cutftp取到的时间总是正确的,不知道他是怎么取的,有谁知道吗?
      

  3.   

    这个是MS的错误。他会把取得文件的时间和GMT时间做比较,如果比GMT时间大就自动减少一年,过了8小时就正确的。
    因为许多FTP服务器的实现是:如果该文件的年份是当前的年份,他下发的时候是不会传年份的。服务服务器是IIS的FTP服务器,把格式设为ms_dos格式就OK了。
      

  4.   

    以前遇到过,咨询过MS,他们承认是他们的API在做时间判断时候的问题,他们也发布过报告,但是我忘记报告的ID了。
      

  5.   

    “不用ms的API就解决了。”那还有什么方法可以取到ftp服务器上的时间呢?
      

  6.   

    或者自己去实现list这个命令(FTP的查看目录命令是不是list我忘了,:p 。),去看一下协议。
      

  7.   

    楼上说的不能解决问题呀,我问的是不用api还有什么办法可以取到服务器上文件的最后修改时间,分不够可以再加,加多少都可以。