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
| Private Sub download()
Dim user As String = "monlogin"
Dim password As String = "monpass"
Dim wc As New WebClient()
wc.Credentials = New NetworkCredential(user, password)
Dim baseUri = "ftp://ftp.cluster006.ovh.net/www/repA/repB/repC/" 'URI et chemin ou je veux aller dans le ftp
Dim newDirectory As String = "../repD/"
Dim fileNames = GetDirectoryListing(baseUri, wc.Credentials)
Dim localpath As String = "\\nas\rep1\rep2\rep3\" 'chemin ou je veux dl les fichiers
For Each filename In fileNames
Dim newPath As String = newDirectory + "/" + filename
If Not filename.EndsWith(".xls", StringComparison.CurrentCultureIgnoreCase) Then 'ne tient pas compte de la casse
Continue For
End If
Dim localFileName = System.IO.Path.Combine(localpath, filename)
Dim uri = baseUri + "/" + filename
wc.DownloadFile(uri, localFileName)
MoveFile(uri, newPath, wc.Credentials) ' transfere le fichier dans done_treatment apres avoir downloade
Next
System.Threading.Thread.Sleep(1000)
Labelprogress.Visible = False
OvalShapeencours.Visible = False
Labeldone.Visible = True
OvalShapedone.Visible = True
End Sub |
Partager