Visual Basic - AYUDA PARA DESCARGAR DIRECTORIO FTP EN CARPETA LOCAL

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

AYUDA PARA DESCARGAR DIRECTORIO FTP EN CARPETA LOCAL

Publicado por Luis (2 intervenciones) el 29/04/2017 04:41:11
HOLA NECESITO ALGUNA AYUDA O RUTINA EN VB5 o VB6 PARA DESCARGAR TODO EL DIRECTORIO RAIZ DE UN FTP COMPUESTO POR ARCHIVOS TXT HASTA UNA CARPETA LOCAL DE MI PC, LO HE INTENTADO CON EL CONTROL INET PERO TENGO ALGUNOS PROBLEMILLAS,,,
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Andres Leonardo
Val: 3.117
Oro
Ha mantenido su posición en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

AYUDA PARA DESCARGAR DIRECTORIO FTP EN CARPETA LOCAL

Publicado por Andres Leonardo (1798 intervenciones) el 30/04/2017 14:36:58
Utilizo el Putty y sirve para ftp y sftp

lo llamo desde un shell

el unico tema es que se arma un archivo .txt con los comandos y luego procesa batch la transferencia lo malo es que visual en ese momento es ciego de lo que procesa putty ... solo sabe que los archivos se estan bajando ...luego puedes revisar el resultado en el contenido de la carpeta

lo otro con inet no tuve problemas ..cual es el tuyo para ver si lo puedo ayudar a corregir-.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

AYUDA PARA DESCARGAR DIRECTORIO FTP EN CARPETA LOCAL

Publicado por Luis Gonzalez (2 intervenciones) el 01/05/2017 05:48:12
hola me gustaria saber si tienes alguna rutina con INET o Putty que me sirva. Yo me encontre esta pero no funciona, solo descarga uno a uno los archivos. Me interesa que la descarga de todo el directorio FTP taiz se haga directamente a una carpeta local. gracias

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Option Explicit
 
 
Private Sub Mostrar_Estado_FTP(ByVal estado As String)
    List1.AddItem estado
    List1.ListIndex = List1.ListCount - 1
End Sub
 
 
Private Sub Command2_Click()
Dim El_Host As String
 
    If txt_Remoto = "" Then
       MsgBox " No hay archivo para descargar", vbInformation
       Exit Sub
    End If
 
        List1.AddItem " ..Descargando "
        'Asigna la Url, es decir el nombre del Host FTP  
        El_Host = "ftp://" & txt_servidor
 
    With Inet1
 
        .URL = El_Host
 
        'nombre de usuario y password de la cuanta FTP  
        .UserName = txt_Usuario
        .Password = txt_Pass
 
        'DEscarga el archivo indicado con el comando Get  
        Call .Execute(, "Get " & txt_Remoto & " " & txt_local)
        DoEvents
 
     End With
End Sub
 
Private Sub Command1_Click()
    Dim El_Host As String
 
    If txt_local = "" Then
       MsgBox " No hay archivo pra subir", vbInformation
       Exit Sub
    End If
 
    List1.AddItem " ..Subiendo archivo "
 
    El_Host = "ftp://" & txt_servidor
 
    With Inet1
 
        'Asigna la Url, es decir el nombre del Host FTP  
        .URL = El_Host
 
        'nombre de usuario y password de la cuanta FTP  
        .UserName = txt_Usuario
        .Password = txt_Pass
 
        'Escribe el fichero en el servidor con el comando Put  
        Call .Execute(, "Put " & txt_local & " " & txt_Remoto)
 
        DoEvents
 
     End With
 
End Sub
 
'botón para seleccionar fichero a subir al Ftp  
Private Sub Command3_Click()
With CommonDialog1
 
     .DialogTitle = " Seleccione el archivo a subir"
     .ShowOpen
 
     If .FileName = "" Then
        txt_local = ""
        Exit Sub
     Else
        txt_local = .FileName
     End If
 
End With
End Sub
 
'botón para seleccionar la ruta y nombre de archivo a descargar  
Private Sub Command4_Click()
With CommonDialog1
 
     .DialogTitle = " Seleccione ruta y nombre del archivo a descargar"
     .ShowSave
 
     If .FileName = "" Then
        txt_Remoto = ""
        Exit Sub
     Else
        txt_Remoto = .FileName
     End If
 
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
 
 
Private Sub Form_Load()
 
    Command1.Caption = "Subir archivo "
    Command2.Caption = " Descargar archivo "
 
    Me.Caption = "Ejemplo del control Inet para descargar y subir ficheros"
 
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Andres Leonardo
Val: 3.117
Oro
Ha mantenido su posición en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

AYUDA PARA DESCARGAR DIRECTORIO FTP EN CARPETA LOCAL

Publicado por Andres Leonardo (1798 intervenciones) el 01/05/2017 18:36:17
hOLA

eSPERO TE SIRVAN
lo vas a llamar asi
1
2
3
Private Sub Command2_Click()
   XXDescargar (false, "*.*")
end SUB




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Private Sub XXDescargar(ind as boolean , DownFile as string)
'PROCEDIMIENTO PARA FTP
'RECIBE DOS PARAMETROS
'IND UN BOOLEANO QUE SI ES INDIVIDUAL O UN varios ARCHIVOS
'DOWNFILE QUE ES EL NOMBRE DEL ARCHIVO INDIVIDUAL O EL STRING DE LOS ARCHIVOS PUEDE SER *.*
 
 
Dim zfiles, zfileList As String
        'Asigna la Url, es decir el nombre del Host FTP
        El_Host = "ftp://192.68.88.15" ' TU ip DE SERVIDOR
 
    With Inet1
 
        .URL = El_Host
        'Nombre de usuario y password de la cuenta FTP
        .UserName = "aguerrero" ' tu usuario
        .Password = "Proce**2006@467" ' tu clave
 
 
        'Descarga el archivo indicado con el comando Get y con Mget
        ''ver los comandos de inet.
 
 
        If IND = True Then  ' esta es una marca si es un solo archivo y en DownFile tiene un nombre especifico  Ej: Contabilidad20170515.txt
            Call .Execute(, "Get " & DownFile & " " & App.Path & "\txt\" & DownFile)
            While .StillExecuting: DoEvents: Wend
        Else
 
        '************************************************************
        ' Cuando es mas de un archivo se hace esto                  *
        ' en DownFile debe ir comodines algo asi como  *.*          *
        ' en DownFile debe ir comodines algo asi como  *20170501.*  *
        '************************************************************
            .Execute .URL, "DIR " & DownFile  ' primero hago un dir de la carpeta para que me de TODOS los archivos
            While .StillExecuting: DoEvents: Wend
 
 
            'Luego  que recupere el dir en un arreglo determino todos los archivos de la carpeta
            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) & " " & "Tu carpeta" & zfiles(i)
                While .StillExecuting: DoEvents: Wend
                i = i + 1
            Wend
 
        End If
        'Esto para que no se quede el pedido
        While .StillExecuting: DoEvents: Wend
 
     End With
 
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar