Option Strict On Imports System.Net Public Class Form1 'déclaration d'un webclient Dim WithEvents download As New WebClient 'déclaration d'une liste qui contient les url a telecharger Dim MaListe As New List(Of String) 'déclaration d'un progressbar ajouté au form Dim prgBar As New ProgressBar With {.Parent Me, .Width 200} Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'bon évidemment là tu changes tes adresses MaListe.Add("http://habdo.comze.com/web_documents/EssentialsSpawn.jar") MaListe.Add("http://habdo.comze.com/web_documents/EssentialsSpawn.jar") MaListe.Add("http://habdo.comze.com/web_documents/EssentialsSpawn.jar") 'téléchargement asynchrone du premier fichier de la liste download.DownloadFileAsync(New Uri(MaListe(0)), MaListe(0).Substring(MaListe(0).LastIndexOf("/") + 1)) 'effacement du premier fichier dans la liste MaListe.RemoveAt(0) End Sub Private Sub download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged 'progressbar mis a jour prgBar.Value = e.ProgressPercentage End Sub Private Sub download_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles download.DownloadFileCompleted 'si la liste est vide on arrête If MaListe.Count = 0 Then Exit Sub ' (voir commentaires ci-dessus) download.DownloadFileAsync(New Uri(MaListe(0)), MaListe(0).Substring(MaListe(0).LastIndexOf("/") + 1)) MaListe.RemoveAt(0) End Sub End Class
Public WithEvents download As WebClient '... download = new WebClient
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question