Home > Software engineering >  Inet control to realize FTP download, download but sometimes is not successful, the application dire
Inet control to realize FTP download, download but sometimes is not successful, the application dire

Time:10-15

Source code is as follows: (hope to solve the problem 1, provide the list form, the login FTP path of files or folders displayed; 2, increase the download judgment, especially the finish to download a file after the program is not have action to download the next file,) for several days, haven't done, first thank you,

Private Sub Command1_Click ()
Dim report_date define public Date As the Date '
Dim check_i As Integer
Check_i=1
Dim path_hd As String 'definition read path
Dim path_namehd As String 'definition name
Dim hdfile_head As String
Path_hd="//hd/"
Hdfile_head="HD"
Path_namehd="handan company"
Report_date=DTPicker1. Value - 1
Call check_report (path_hd, path_namehd report_date, hdfile_head, check_i)
End Sub

Sub check_report (path As String, the name As a String, pre_date As the Date, file_head As String, excel_i As Integer)
Dim str_together As String
Dim filehead_together As String
Dim reach_record As String
Dim disreach_record As String
Filehead_together=filehead_together + Format (pre_date, "YYYYMMDD")
Str_together=path + Format (pre_date, "YYYYMMDD")
'the Debug. Print str_together
Rc.inet1. URL="192.168.2.11/"
Rc.inet1. UserName="xiexie"
Rc.inet1. Password="ZHBXST"
Onerr goto Proc_Exit:
Rc.inet1. AccessType=icUseDefault 'setting and the type of Internet connection, the default
Rc.inet1. Protocol=icFTP
Rc.inet1. RemotePort=21
Rc.inet1. Cancel
On Error GoTo Proc_Exit

Rc.inet1. Execute rc.inet1 URL, "dir" & amp; "/"

The Do While rc.inet1. StillExecuting
DoEvents
Loop

Rc.inet1. Execute rc.inet1. URL, "GET" & amp; Str_together & amp; ". XLS "& amp; App. The path & amp; "" & amp; File_head & amp; Filehead_together & amp; ". XLS "
The Do While rc.inet1. StillExecuting
DoEvents
Loop

If Dir (App. Path & amp; "" & amp; File_head & amp; Filehead_together & amp; ". XLS ")="" Then
Open the App. The path & amp; "\ JKRB. TXT" For Append As # 1
Print # 1, reach_record
Close # 1
The Else
Disreach_record=disreach_record + name & amp; "JKRB
"
Open the App. The path & amp; "\ JKRB. TXT" For Append As # 1
Print # 1, disreach_record
Close # 1
End the If
Proc_Exit:
Then If Err. Number=- 2147467259
'Resume
MsgBox "database connection failed, please check the network environment, program exits!! ~ ", 16, "error"
End
'Fpross. StatusBar1. Panels (1)="database connection failed!"
ElseIf Err. Number=35754 Then
MsgBox "FTP server connection failed, please check the network environment, the program exits!" , 16, "error"
End


End the If

End Sub

CodePudding user response:

Top by oneself,

CodePudding user response:

More try so hard, the environment,

CodePudding user response:

Thanks for sharing, learning,
  • Related