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.
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.
给我一份
[email protected]