Hi to all,
ok, I'm trying to download several files,when I run the process step by step (F8) it works like a charm, but when I run it all at once I get the error message => Error:Still executing last request.
This ocurrs because after I login(logon function) to the server and change to another directory(inet1.execute, "CD directory) when I try to do a DIR (inet1.execute, "DIR ")so I can get the files that are in that directory ( vtData = frmExplore.Inet1.GetChunk(1024, icString) ) the error jumps out.
I have confirm that if I take out the DIR instruction (inet1.execute, "DIR ") the error is corrected ,but GETCHUNK does not get the files.
what can I do???? Should I apply the mget or VB6 does not support it
Thank you all
This is the code :
========= this function is to login to the server =========
Public Sub logon() 'ByVal choice As Integer)
On Error GoTo LogOnError
.
.
.
frmExplore.Inet1.Protocol = icFTP
frmExplore.Inet1.URL = address1
If usName1 = "" Then
frmExplore.Inet1.UserName = "anonymous"
Else
frmExplore.Inet1.UserName = usName1
End If
frmExplore.Inet1.Password = Passwd1
frmExplore.Inet1.Execute , "DIR"
Exit Sub
LogOnError:
If Err = 35754 Then
MsgBox "Cannot connect to the remote host"
Else
MsgBox Err.Description
End If
frmExplore.Inet1.cancel
End Sub
'============= check if the INET is READY =============
Public Function inetReady(Message As Boolean) As Boolean
On Error GoTo errhandler
Dim msg As String
Dim i As Long
Do While frmExplore.Inet1.StillExecuting = True
DoEvents
Loop
inetReady = True
Exit Function
errhandler:
MsgBox Err.Source & " " & Err.Number & " " & Err.Description
End Function
================== to execute the command ================
Public Sub SendCommand(ByVal cmd As String)
'envia el comando al server del FTP
On Error GoTo SendCommandErr
frmExplore.Inet1.Execute , cmd
Exit Sub
SendCommandErr:
MsgBox "Error: " & Err.Description
Resume Next
End Sub
============== to download the files ===================
Public Sub loadreports(ByVal direccione As String)
.
.
.
'change to outbond directory
Dim varr As String
varr = "CD outbound"
If inetReady(True) Then
Call SendCommand(varr)
End If
**********************************
'update the directory *
frmExplore.Inet1.Execute , "DIR" *
**********************************
'get list of the files in that directory
vtData = frmExplore.Inet1.GetChunk(1024, icString)
DoEvents
'Get all Information, pass it to a compatible variable
Do While Not bDone
strData = strData & vtData
If Len(vtData) <> 0 Then
bDone = True
End If
Loop
'keep the name of the existent files in an array
lsItems = Split(strData, vbCrLf)
For z = 0 To UBound(lsItems)
lsItem = Trim$(lsItems(z))
If lsItem <> "" Then
If Right$(lsItem, 1) <> "/" Then
loadarray(j) = lsItem
j = j + 1
Else
End If
End If
Next
'download the files
Do While loadarray(i) <> ""
var = loadarray(i)
cmd = "GET " & var & " " & direccion & var
If inetReady(True) Then
Call SendCommand(cmd)
End If
i = i + 1
Loop
'close the conection
varr = "CLOSE "
If inetReady(True) Then
Call SendCommand(varr)
End If
'erase the encrypted and leave the originals
i = 1
Dim name As String
Do While loadarray(i) <> ""
name = loadarray(i)
datain = direccion & name
var2 = Len(name) - 4
resul = Left(name, var2)
dataout = direccion & resul
Call fso.DecryptFile(pubkeyring, privkeyring, datain, dataout, passwd)
fso2.DeleteFile datain, True
i = i + 1
Loop
Exit Sub
GetRemoteFileErr:
MsgBox "Error: " & Err.Description
Resume Next
End Sub
ok, I'm trying to download several files,when I run the process step by step (F8) it works like a charm, but when I run it all at once I get the error message => Error:Still executing last request.
This ocurrs because after I login(logon function) to the server and change to another directory(inet1.execute, "CD directory) when I try to do a DIR (inet1.execute, "DIR ")so I can get the files that are in that directory ( vtData = frmExplore.Inet1.GetChunk(1024, icString) ) the error jumps out.
I have confirm that if I take out the DIR instruction (inet1.execute, "DIR ") the error is corrected ,but GETCHUNK does not get the files.
what can I do???? Should I apply the mget or VB6 does not support it
Thank you all
This is the code :
========= this function is to login to the server =========
Public Sub logon() 'ByVal choice As Integer)
On Error GoTo LogOnError
.
.
.
frmExplore.Inet1.Protocol = icFTP
frmExplore.Inet1.URL = address1
If usName1 = "" Then
frmExplore.Inet1.UserName = "anonymous"
Else
frmExplore.Inet1.UserName = usName1
End If
frmExplore.Inet1.Password = Passwd1
frmExplore.Inet1.Execute , "DIR"
Exit Sub
LogOnError:
If Err = 35754 Then
MsgBox "Cannot connect to the remote host"
Else
MsgBox Err.Description
End If
frmExplore.Inet1.cancel
End Sub
'============= check if the INET is READY =============
Public Function inetReady(Message As Boolean) As Boolean
On Error GoTo errhandler
Dim msg As String
Dim i As Long
Do While frmExplore.Inet1.StillExecuting = True
DoEvents
Loop
inetReady = True
Exit Function
errhandler:
MsgBox Err.Source & " " & Err.Number & " " & Err.Description
End Function
================== to execute the command ================
Public Sub SendCommand(ByVal cmd As String)
'envia el comando al server del FTP
On Error GoTo SendCommandErr
frmExplore.Inet1.Execute , cmd
Exit Sub
SendCommandErr:
MsgBox "Error: " & Err.Description
Resume Next
End Sub
============== to download the files ===================
Public Sub loadreports(ByVal direccione As String)
.
.
.
'change to outbond directory
Dim varr As String
varr = "CD outbound"
If inetReady(True) Then
Call SendCommand(varr)
End If
**********************************
'update the directory *
frmExplore.Inet1.Execute , "DIR" *
**********************************
'get list of the files in that directory
vtData = frmExplore.Inet1.GetChunk(1024, icString)
DoEvents
'Get all Information, pass it to a compatible variable
Do While Not bDone
strData = strData & vtData
If Len(vtData) <> 0 Then
bDone = True
End If
Loop
'keep the name of the existent files in an array
lsItems = Split(strData, vbCrLf)
For z = 0 To UBound(lsItems)
lsItem = Trim$(lsItems(z))
If lsItem <> "" Then
If Right$(lsItem, 1) <> "/" Then
loadarray(j) = lsItem
j = j + 1
Else
End If
End If
Next
'download the files
Do While loadarray(i) <> ""
var = loadarray(i)
cmd = "GET " & var & " " & direccion & var
If inetReady(True) Then
Call SendCommand(cmd)
End If
i = i + 1
Loop
'close the conection
varr = "CLOSE "
If inetReady(True) Then
Call SendCommand(varr)
End If
'erase the encrypted and leave the originals
i = 1
Dim name As String
Do While loadarray(i) <> ""
name = loadarray(i)
datain = direccion & name
var2 = Len(name) - 4
resul = Left(name, var2)
dataout = direccion & resul
Call fso.DecryptFile(pubkeyring, privkeyring, datain, dataout, passwd)
fso2.DeleteFile datain, True
i = i + 1
Loop
Exit Sub
GetRemoteFileErr:
MsgBox "Error: " & Err.Description
Resume Next
End Sub