Bonjour,
je développe une application qui contient un installateur.
L'utilisateur sélectionne les éléments à télécharger et à installer.
Ma Form dispose d'une progressebar, d'un label et d'une listbox.
je souhaite que pour l'étape de téléchargement, la progressebar avance dès qu'un élément parmi ceux sélectionnés est téléchargé et que son nom apparaisse dans la listbox. De plus, je souhaite que l'url du site sur lequel l'élément est téléchargé soit affichée avec le label.
J'ai un dictionnaire contenant pour chaque élément, l'url de téléchargement correspondante :
(Pour des raisons de sécurité, l'adresse URL est replacé par ****)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Sub CreateDicoPath() Try If My.Settings.type = "p/l" Then dicopath.Add("ResEqua (1.0)", "****/Ind6x/download/software/ResEqua.zip") dicopath.Add("CanFormer (1.0)", "****/Ind6x/download/software/CanFormer.zip") dicopath.Add("CylinderSt (1.0)", "****/Ind6x/download/software/CylinderSt.zip") dicopath.Add("TPE - Atterrissage (1.0)", "****/Ind6x/download/software/TPE-Atterrissage.zip") dicopath.Add("AutoFlightPlan (1.0)", "****/Ind6x/download/software/AutoFlightPlan.zip") dicopath.Add("RunFolder (1.0)", "****/Ind6x/download/software/RunFolder.zip") dicopath.Add("SpamKey (1.0)", "****/Ind6x/download/software/SpamKey.zip") dicopath.Add("Spwords (1.0)", "****/Ind6x/download/software/Spwords.zip") dicopath.Add("AdrnSVT (1.0)", "****/Ind6x/download/software/AdrnSVT.zip") Else dicopath.Add("Livrée Bell 206b Croatian Air Force", "****/Ind6x/download/fsx/") dicopath.Add("Livrée MIG-21 Croatian Air Force", "****/Ind6x/download/fsx/") dicopath.Add("Livrée Boeing 737-800 Hellfest 2016", "****Ind6x/download/fsx/") dicopath.Add("Scène Tromelin (AFT) Version_01", "****/Ind6x/download/fsx/") dicopath.Add("Scène Tromelin (AFT) Version_02", "****/Ind6x/download/fsx/") End If Catch ex As Exception MsgBox("An error has occurred, the application will restart") Application.Restart() End Try End Sub
Le téléchargement a pour code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Sub download() Try For Each item In listinstall Label2.Text = dicopath(item) Listbox1.Items.Add(item) My.Computer.Network.DownloadFile(dicopath(item), path & "\" & item & ".zip") ProgressBar1.Value += progress Next Catch ex As Exception MsgBox("An error has occurred, the application will restart") Application.Restart() End Try End Sub
La création du dictionnaire ainsi que l'appel de la procédure est exécutée par ce code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click Button2.Enabled = False Call CreateDicoPath() Call download() End Sub
NB: progress = 100/nbr d'éléments à télécharger
Mon probleme :
Le téléchargement s'effectue bien et la progressebar progresse (^^) correctement au fur et à mesure.
cepandant, Les éléments téléchargés ne s'affiche dans la listbox qu'a la fin du téléchargement et le label ne me retourne que la dernière URL utilisé et a la fin seulement aussi. Comme si une priorité avait été fixée pour le téléchargement et que le reste ne s’exécute qu'une fois celui ci terminé...
Merci de votre aide !!
Partager