Hiyas
I have some code which I got from a tutorial which downloads a directory listing from an ftp site, I want to convert the code so that it downloads files but the examples I've found won't work - can anyone tell me hoe to change to file transfer - tutorials seem to think ist easy - but I can't get my head round it!
Heres my code:
Private Sub Command1_Click()
Inet1.URL = "ftp://ftp.somesite.com/directory/"
Inet1.UserName = "Username"
Inet1.Password = "Password"
Inet1.Execute , "DIR"
'If I comment out the line above & introduce th line below -'I should transfer a file - but It won't work
'can anyone tell me whats wrong?
'Inet1.Execute , "GET file.txt C:\file.txt"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant ' Data variable.
Select Case State
' ... Other cases not shown.
Case icError ' 11
' In case of error, return ResponseCode and
' ResponseInfo.
vtData = Inet1.ResponseCode & ":" & _
Inet1.ResponseInfo
Case icResponseCompleted ' 12
Dim strData As String: strData = ""
Dim bDone As Boolean: bDone = False
' Get first chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents
Do While Not bDone
strData = strData & vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents
If Len(vtData) = 0 Then
bDone = True
End If
Loop
MsgBox State 'strData
End Select
End Sub
Cheers 'n' beers
Skeen




Reply With Quote