我想从ftp服务器的data2目录中,把扩展名为.log的文本文件都下载到程序所在目录
代码如下:
Dim AryFile() As StringPrivate Sub Command1_Click()
Dim I As Integer
Dim RF As String, LF As String
Dim FN As Integer
With Inet1
.Protocol = icFTP
.URL = "116.116.13.25"
.UserName = ""
.Password = ""
.Execute , "CD data2"
Do While .StillExecuting
DoEvents
Loop
.Execute , "DIR"
Do While .StillExecuting
DoEvents
Loop
End With
For I = LBound(AryFile) To UBound(AryFile) If UCase(Right(AryFile(I), 4)) = ".LOG" Then
RF = AryFile(I)
LF = App.Path & "\" & AryFile(I)
Inet1.Execute , "GET " & RF & " " & LF
Do While Inet1.StillExecuting
DoEvents
Loop
End If Next
MsgBox "Complete"
Inet1.Execute "CLOSE"
End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Dim data1 As String
Dim Label1 As String
Dim I As Integer
Select Case State
Case 12
Label1 = "响应完成" '"Response Completed"
Do While True
'Change datatype to icByteArray to receive data in binary
data1 = Inet1.GetChunk(512, icString)
If Len(data1) = 0 Then Exit Do
DoEvents 'Transfer control to operating system
AryFile = Split(data1, Chr(13))
For I = LBound(AryFile) To UBound(AryFile)
lstDir.AddItem AryFile(I)
Next
Loop
End Select
lstResponse.AddItem Label1
lstResponse.ListIndex = lstResponse.ListCount - 1
End Sub问题:log文件有很多个,但程序执行每次都只能下载第一个,也没看到报错,请问是什么问题?
代码如下:
Dim AryFile() As StringPrivate Sub Command1_Click()
Dim I As Integer
Dim RF As String, LF As String
Dim FN As Integer
With Inet1
.Protocol = icFTP
.URL = "116.116.13.25"
.UserName = ""
.Password = ""
.Execute , "CD data2"
Do While .StillExecuting
DoEvents
Loop
.Execute , "DIR"
Do While .StillExecuting
DoEvents
Loop
End With
For I = LBound(AryFile) To UBound(AryFile) If UCase(Right(AryFile(I), 4)) = ".LOG" Then
RF = AryFile(I)
LF = App.Path & "\" & AryFile(I)
Inet1.Execute , "GET " & RF & " " & LF
Do While Inet1.StillExecuting
DoEvents
Loop
End If Next
MsgBox "Complete"
Inet1.Execute "CLOSE"
End SubPrivate Sub Inet1_StateChanged(ByVal State As Integer)
Dim data1 As String
Dim Label1 As String
Dim I As Integer
Select Case State
Case 12
Label1 = "响应完成" '"Response Completed"
Do While True
'Change datatype to icByteArray to receive data in binary
data1 = Inet1.GetChunk(512, icString)
If Len(data1) = 0 Then Exit Do
DoEvents 'Transfer control to operating system
AryFile = Split(data1, Chr(13))
For I = LBound(AryFile) To UBound(AryFile)
lstDir.AddItem AryFile(I)
Next
Loop
End Select
lstResponse.AddItem Label1
lstResponse.ListIndex = lstResponse.ListCount - 1
End Sub问题:log文件有很多个,但程序执行每次都只能下载第一个,也没看到报错,请问是什么问题?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货