niketou
Messages postés295Date d'inscriptiondimanche 4 mai 2003StatutMembreDernière intervention 6 décembre 2010
-
23 août 2003 à 23:13
pcpunch
Messages postés1243Date d'inscriptionmardi 7 mai 2002StatutMembreDernière intervention18 février 2019
-
24 août 2003 à 23:41
salut,quelqu'un sait comment telecharger tout les fichiers du dossier d'un site ou fpt,mais d'un dossier precis (ex:www.monsite.com/dossier/).
merci
pcpunch
Messages postés1243Date d'inscriptionmardi 7 mai 2002StatutMembreDernière intervention18 février 20195 24 août 2003 à 23:41
Voici une fonction pour telecharger tous les fichiers d'un dossier sur un ftp!!
Public Function CopieFichierFtp(Url As String, Dossier As String, Destination As String)
Dim Reponse As String
'Declare l'url
Inet1.Url = Url
'Se place dans le dossier "dossier" de la racine du ftp
Inet1.Execute , "cd " & Dossier & "/"
Call InetAttente
'Lit le contenu
Inet1.Execute , "dir"
Call InetAttente
'Stocke la reponse du dir
Reponse = Inet1.GetChunk(1024)
Call InetAttente
'Decoupe de reponse pour recupération des fichiers
Dim Nom_Fic()
Dim Nb As Integer
Dim Tmp As String
Nb = 0
For i = 1 To Len(Reponse)If Mid(Reponse, i, 1) Chr(13) And Mid(Reponse, i + 1, 1) Chr(10) Then
Tmp = Replace(Tmp, Chr(13), "")
Tmp = Replace(Tmp, Chr(10), "")
If Mid(Tmp, 1, 1) <> "." And Tmp <> "" Then
ReDim Preserve Nom_Fic(Nb)
Nom_Fic(Nb) = Tmp
Nb = Nb + 1
Tmp = ""
Else
Tmp = ""
End If
Else
Tmp = Tmp & Mid(Reponse, i, 1)
End If
Next i
'recuperation du path du ftp
Dim PathFtp As String
Inet1.Execute , "pwd"
Call InetAttente
PathFtp = Inet1.GetChunk(1024)
Call InetAttente
'Copie des fichiers du ftp
For i = 0 To UBound(Nom_Fic)
'Affichage de l'operation en cours
Label1 = "Copie de " & Nom_Fic(i) & " vers " & Destination
Inet1.Execute , "get " & PathFtp & "/" & Nom_Fic(i) & " " & Destination & Nom_Fic(i)
InetAttente
Next i
End Function
Sub InetAttente()
Do While Inet1.StillExecuting = True
DoEvents
Loop
End Sub
'POUR L'utiliser EXEMPLE :
Private Sub Command1_Click()
CopieFichierFtp "Ftp://user:pass@ftp", "dossier/sousdossier", "c:\test"
End Sub
'Si exemple les fichier se trouve dans le dossier : image
CopieFichierFtp "Ftp://user:pass@ftp", "image", "c:\test"