引用Microsoft Internet Transfer Controls6.0 '下载函数 Public Sub DownLoadFile(SourceFile As String, DestFile As String) On Error GoTo LocalError Inet1.Execute "GET " & SourceFile & " " & DestFile Do While Inet1.StillExecuting = True DoEvents Loop If LoggingState = True Then Print #1, Now & " Response on download: " & Inet1.ResponseInfo End If
Exit Sub LocalError: If Err.Number <> 0 Then Err.Raise Err.Number, Err.Source, Err.Description End If End Sub'连接函数 Public Sub Connect(Optional ByVal FtpUrl As String, Optional ByVal Username As String, Optional ByVal PassWord As String) On Error Resume Next Inet1.Cancel
Inet1.Execute , "DIR" Do While Inet1.StillExecuting DoEvents Loop Exit Sub LocalError: Inet1.Cancel If Err.Number <> 0 Then Err.Raise Err.Number, Err.Source, Err.Description End If End Sub
Inet1.OpenURL "http://sc-down.downloadsky.com/down/absolute_483.zip", 0然后呢?
'下载函数
Public Sub DownLoadFile(SourceFile As String, DestFile As String)
On Error GoTo LocalError
Inet1.Execute "GET " & SourceFile & " " & DestFile
Do While Inet1.StillExecuting = True
DoEvents
Loop
If LoggingState = True Then
Print #1, Now & " Response on download: " & Inet1.ResponseInfo
End If
Exit Sub
LocalError:
If Err.Number <> 0 Then
Err.Raise Err.Number, Err.Source, Err.Description
End If
End Sub'连接函数
Public Sub Connect(Optional ByVal FtpUrl As String, Optional ByVal Username As String, Optional ByVal PassWord As String)
On Error Resume Next
Inet1.Cancel
On Error GoTo LocalError
Inet1.AccessType = icUseDefault
Inet1.URL = FtpUrl
Inet1.Username = Username
Inet1.PassWord = PassWord
Inet1.RequestTimeout = 40
Inet1.Execute , "DIR"
Do While Inet1.StillExecuting
DoEvents
Loop
Exit Sub
LocalError:
Inet1.Cancel
If Err.Number <> 0 Then
Err.Raise Err.Number, Err.Source, Err.Description
End If
End Sub