strCommand = "REST 5"
  Debug.Print strCommand
  bRet = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, _
                    strCommand, 0, hFile)
  Debug.Print "FTP server supports RESUME function: " & bRet
  ' We are reading server reply from the control connection
  Debug.Print GetFTPServerReply
  
  DoEvents
  ' Let's reset pointer to 0, so that we download all data file
  strCommand = "REST 0"
  Debug.Print strCommand
  bRet = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, _
                      strCommand, 0, hFile)
  ' We are reading server reply from the control connection
  Debug.Print GetFTPServerReply
  DoEvents
  
  
  strCommand = "TYPE A"
  Debug.Print strCommand
  bRet = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, strCommand, 0, hFile)
  Debug.Print GetFTPServerReply
  DoEvents
  
  strCommand = "PASV"
  Debug.Print strCommand
  bRet = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, strCommand, 0, hFile)
  Debug.Print GetFTPServerReply
  DoEvents
  
  strCommand = "LIST /成功.rar"
  Debug.Print strCommand
  bRet = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, strCommand, 0, hFile)
  Debug.Print GetFTPServerReply
  DoEvents
  
  strCommand = "TYPE I"
  Debug.Print strCommand
  bRet = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, strCommand, 0, hFile)
  Debug.Print GetFTPServerReply
  DoEvents 'Fri Sep 16 09:58:11 2005 SIZE /D:/新建 WinRAR 压缩文件.rar
  
  strCommand = "SIZE /成功.rar"
  Debug.Print strCommand
  bRet = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, strCommand, 0, hFile)
  Debug.Print GetFTPServerReply
  DoEvents
  
  strCommand = "RETR /成功.rar"
  Debug.Print strCommand
  bRet = FtpCommand(hConnection, False, dwType, strCommand, 0, hFile)
  '这里返回150
  DoEvents
  Debug.Print GetFTPServerReply  问题:发送"RETR /成功.rar"后,hFile还为0,即使把False改成True,也是为0.
  如果ftpcommand发送Retr成功用什么语句来下载呢?InternetReadFile或是FtpOpenFilePrivate Function GetFTPServerReply() As String
 
  Dim dwIntError As Long, dwLength As Long
  Dim strCommand As String
 
  ' We are reading server reply from the control connection
  InternetGetLastResponseInfo dwIntError, vbNullString, dwLength
  strCommand = String(dwLength + 1, 0)
  InternetGetLastResponseInfo dwIntError, strCommand, dwLength
  GetFTPServerReply = strCommand
 
End Function'下面是返回的信息
220 TYPSoft FTP Server 1.07 ready...
331 Password required for server.
230 User server logged in.
  
REST 5
FTP server supports RESUME function: True
350 REST supported. Ready to resume at byte offset 5.
  
REST 0
350 REST supported. Ready to resume at byte offset 0.
  
TYPE A
200 Type set to A.
  
PASV
227 Entering Passive Mode (202,101,71,46,19,99).
  
LIST /编译成功.rar
150 Opening data connection for directory list.
  
TYPE I
200 Type set to I.
  
SIZE /编译成功.rar
213 287163
  
RETR /编译成功.rar
150 Opening data connection for /编译成功.rar.
  

解决方案 »

  1.   

    谢谢请各位VB爱好者,我以经解决了,想要这段代码的请留下邮箱,用API实现FTP下载并支持断点,网上只提到怎么做,而没有代码,http://www.vbip.com/wininet/wininet-ftp-command-01.asp这个网址也讲得非常明白了,可是我拿来试怎么试都不成功,今天我才发现,原来是API申明的问题,而http://community.csdn.net/Expert/topic/4207/4207200.xml?temp=9.591311E-02也是我发的,里面的 province_(雍昊) 他说API不能实现,我今天实现了
      

  2.   

    兄台:
    给我一份
    [email protected]