DownLoadFtp




'Declare variables for URL, location of file on server,

'and destination pathname for file on hard disk

Dim strUrl As String'URL is ftp site
Dim strSource As String
Dim strDest As String
Private Sub Command1_Click()
'Connect to ftp site and copy file to hard disk

strUrl = txtURLbox.Text'get URL from user
strSource = txtServerPath.Text 'get path to source file
strDest = txtLocalPath.Text'get destination path
'Use Execute method and GET operation to copy file

Inet1.Execute strUrl, "GET " & strSource & " " & strDest
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
'This event is triggered when the control completes

'various tasks, like connecting and logging errors

Dim strAllText As String 'dim two variables For
Dim strLine As String'displaying text file
'When the transfer is complete or an error occurs,

'process the state appropriately

Select Case State
Case icError'if there is an error, describe it
If Inet1.ResponseCode = 80 Then 'file exists Error
MsgBox "File Exists! Please specify new destination"
Else'if not code 80, Then show unknown Error
MsgBox Inet1.ResponseInfo, , "File transfer failed"
End If
Case icResponseCompleted 'if ftp successful
If Option1.Value = True Then 'and display requested
Open strDest For Input As #1 'open in text box
Do Until EOF(1)
Line Input #1, strLine'read each line
strAllText = strAllText & strLine & vbCrLf
Loop
Close #1
txtNote.Text = strAllText'copy to text box
Else 'if the user selects no text display (default)
txtNote.Text = "" 'simply announce completion
MsgBox "Transfer complete", , strDest
End If
End Select
End Sub

Assumes:
make 3 labels
one named txtURLbox,
one named txtServerPath
one named txtLocalPath,
a frame, two command buttons










( downloadftp.html )- by Paolo Puglisi - Modifica del 17/12/2023