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
| Private Sub download()
Dim user As String = "monlogin"
Dim password As String = "monpassword"
Dim wc As New WebClient()
wc.Credentials = New NetworkCredential(user, password)
Dim baseUri = "ftp://ftp.cluster006.ovh.net/www/jdownloads/Patient/new_treatment/" 'URI et chemin ou je veux aller dans le ftp
Dim newDirectory As String = "../done_treatment/"
Dim fileNames = GetDirectoryListing(baseUri, wc.Credentials)
Dim localpath As String = "\\nas\Calculateur\DATA\encours\" '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
Me.Enabled = True
End Sub |
Partager