'the FTP download file
Public Function DownLoadFile (IP As String, FileName As String, LocalFileName As String, UserName As the String, PassWord As String, ByVal FtpSubdirectory As String) As Boolean
On Error GoTo f_Error
Dim Ret As Boolean
Dim FTP_FileName As String
If Len (FtpSubdirectory) & gt; 0 Then
FTP_FileName="" & amp; Trim (FtpSubdirectory) & amp; "" & amp; FileName
The Else
FTP_FileName=FileName
End the If
HOpen=TestServer
If hOpen & lt;> 0 Then
HConnection=InterConnection (IP, UserName, PassWord)
If hConnection & lt;> 0 Then
'ret=FtpGetFile (hConnection, FileName, LocalFileName, 0, 0, 1, 0)
'DownLoadFile=ret
FtpGetFile hConnection FTP_FileName, LocalFileName, 0, 0, 2, 0
'the first parameter is hFtpSession InternetConnect call returns a handle to the value,
'lpszRemoteFile lpszNewFile is the name of the file on the FTP server), and will create the name of the file on the local machine?
'fFailIfExists logo is 0 (replace local file) or 1 (if the local file already exists, cancel),
File attributes' dwFlagsAndAttributes used to specify a local file?
'dwFlags parameter is specified as 1 transfer files in ASCII (class A transfer method), designated for 2 is A transfer files in binary (1 class transfer method),
'in the end, when using callback signals, lContext used to identify the relationship between before and after the application,
'if the function call is successful, blnRC to True, instead to False,
DownLoadFile=(GetLastError & lt;> ERROR_INTERNET_EXTENDED_ERROR)
The Else
DownLoadFile=False
End the If
The Else
DownLoadFile=False
End the If
InternetCloseHandle hConnection
InternetCloseHandle hOpen
The Exit Function
F_Error:
MsgBox "error code:" & amp; Err. Number & amp; CRH (13) & amp; Err. Source & amp; ":" & amp; Err. Description, vbExclamation, "tip"
End Function