Private Sub Descargar()
Dim zfiles, zfileList As String
p = 8
q = 9
Ind = true ' por que solo tienes un archivo si fueran varios 12345*.* va a false
DownFile = "12345.jpg" ' si fueran varios sera 12345*.*
'Asigna la Url, es decir el nombre del Host FTP
El_Host = "ftp://IP SERVIDOR"
With Inet1
.Url = El_Host
'Nombre de usuario y password de la cuenta FTP
.UserName = "aguerrero"
.Password = "PassPrueba"
'Descarga el archivo indicado con el comando Get y con Mget
''ver los comandos de inet.
grabalog "Descargando " & DownFile
If IND = True Then ' Esta variable dice si el archivo es UNICO o hay varios con el mismo nombre
Call .Execute(, "Get " & DownFile & " " & App.Path & "\txt\" & DownFile) 'Mid(DownFile, 1, 20) & Format(Time, "hhmmss") & ".txt")
While .StillExecuting: DoEvents: Wend
Else
'************************************************************
' Cuando es mas de un archivo se hace esto *
'************************************************************
.Execute .Url, "DIR " & DownFile
While .StillExecuting: DoEvents: Wend
'Luego en un arreglo determino todos los archivos del dia por lo general 2
zfileList = .GetChunk(4096, 0)
zfiles = Split(zfileList, vbCrLf)
i = 0
'Y luego solo Los Bajo Uno a Uno respecto a mi criterio de Listar Archivos....
While (i < UBound(zfiles) - 1)
.Execute .Url, "GET " & zfiles(i) & " " & App.Path & "\txt\" & zfiles(i)
While .StillExecuting: DoEvents: Wend
i = i + 1
Wend
End If
While .StillExecuting: DoEvents: Wen
End With
End Sub
Private Sub Inet1_StateChanged(ByVal state As Integer)
Select Case state
'Dependiendo del valor recibido de State _
muestra en el List1 la información de estado
Case 0: Mostrar_Estado_FTP " Nothing "
Case 1: Mostrar_Estado_FTP " Resolviendo Host "
Case 2: Mostrar_Estado_FTP " Host Resuelto "
Case 3: Mostrar_Estado_FTP " Conectando a: " & txt_servidor
Case 4: Mostrar_Estado_FTP " Conectado a " & txt_servidor
Case 5: Mostrar_Estado_FTP " Petición"
Case 6: Mostrar_Estado_FTP " Enviando petición"
Case 7: Mostrar_Estado_FTP " Recibiendo Respuesta "
Case 8: Mostrar_Estado_FTP " Respuesta recibida "
Case 9: Mostrar_Estado_FTP " Desconectando "
Case 10: Mostrar_Estado_FTP " Estado : Desconectado"
Case 11: Mostrar_Estado_FTP " Error: " & Inet1.ResponseInfo
Case 12: Mostrar_Estado_FTP Inet1.ResponseInfo
Case Else: Mostrar_Estado_FTP " Estado -> " & Format$(state)
End Select
DoEvents
End Sub