Bonjour à tous, je me lance dans le codage en VB pour réaliser un launcher, c'est a dire un petit programme qui se lance avant l'exécution d'un jeu, et qui vérifie que tous les fichiers du jeu sont à jour, tout d'abord, voici le code :
Mon problème :
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("Vérification des fichiers pour la mise à jour, veuillez patienter", MsgBoxStyle.Exclamation) Timer1.Start() Button7.Show() Button1.Hide() If System.IO.Directory.Exists(Environment.SpecialFolder.Desktop & "\Extazy") = True Then Kill("C:\Program Files\Extazy\Config.xml") Kill("C:\Program Files\Extazy\Modules\Core.swf") Kill("C:\Program Files\Extazy\Modules\Soma.swf") Kill("C:\Program Files\Extazy\Loader.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/86436lt21a6m071/config.xml", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Config.xml") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/8gmyfgycmh0husb/core.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Core.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/420i9kefgasacvh/soma.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Soma.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/5bjchf3azv5bhrd/loader.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Loader.swf") ElseIf System.IO.Directory.Exists(Environment.SpecialFolder.Desktop & "\Extazy") = False Then My.Computer.Network.DownloadFile("https://www.dropbox.com/s/86436lt21a6m071/config.xml", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Config.xml") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/8gmyfgycmh0husb/core.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Core.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/420i9kefgasacvh/soma.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Soma.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/5bjchf3azv5bhrd/loader.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Loader.swf") End If MsgBox("Mise à jour terminée, le jeu va se lancer automatiquement", MsgBoxStyle.Information) Shell("C:\Desktop\Extazy\Extazy.exe") Me.Close() End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Button2.Show() Button3.Hide() Button4.Hide() Button5.Hide() Button6.Hide() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Button2.Hide() Button3.Show() Button4.Show() Button5.Show() Button6.Show() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click System.Diagnostics.Process.Start("http://25.32.190.92/site.php") End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click System.Diagnostics.Process.Start("http://sectionxiii.xooit.com") End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click System.Diagnostics.Process.Start("http://25.32.190.92/vote.php") End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Button1.Show() Button2.Show() Button3.Hide() Button4.Hide() Button5.Hide() Button6.Hide() Button7.Hide() End Sub Private Sub ProgressBar1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click Timer1.Stop() ProgressBar1.Value = 0 End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ProgressBar1.Value += 1 End Sub End Class
Je décortique :
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 If System.IO.Directory.Exists(Environment.SpecialFolder.Desktop & "\Extazy") = True Then Kill("C:\Program Files\Extazy\Config.xml") Kill("C:\Program Files\Extazy\Modules\Core.swf") Kill("C:\Program Files\Extazy\Modules\Soma.swf") Kill("C:\Program Files\Extazy\Loader.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/86436lt21a6m071/config.xml", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Config.xml") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/8gmyfgycmh0husb/core.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Core.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/420i9kefgasacvh/soma.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Soma.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/5bjchf3azv5bhrd/loader.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Loader.swf") ElseIf System.IO.Directory.Exists(Environment.SpecialFolder.Desktop & "\Extazy") = False Then My.Computer.Network.DownloadFile("https://www.dropbox.com/s/86436lt21a6m071/config.xml", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Config.xml") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/8gmyfgycmh0husb/core.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Core.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/420i9kefgasacvh/soma.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Soma.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/5bjchf3azv5bhrd/loader.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Loader.swf") End If MsgBox("Mise à jour terminée, le jeu va se lancer automatiquement", MsgBoxStyle.Information)
Si je ne me trompe pas il vérifie que le dossier "Extazy" existe sur le bureau.
Code : Sélectionner tout - Visualiser dans une fenêtre à part If System.IO.Directory.Exists(Environment.SpecialFolder.Desktop & "\Extazy") = True Then
Normalement, si le dossier Extazy existe sur le bureau, il efface (kill) le fichier qui existe puis télécharge la version qui est à l'adresse spécifiée.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 Kill("C:\Program Files\Extazy\Config.xml") Kill("C:\Program Files\Extazy\Modules\Core.swf") Kill("C:\Program Files\Extazy\Modules\Soma.swf") Kill("C:\Program Files\Extazy\Loader.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/86436lt21a6m071/config.xml", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Config.xml") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/8gmyfgycmh0husb/core.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Core.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/420i9kefgasacvh/soma.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Modules\Soma.swf") My.Computer.Network.DownloadFile("https://www.dropbox.com/s/5bjchf3azv5bhrd/loader.swf", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Loader.swf")
Et si le dossier n'existe pas, il le crée simplement pour ne pas faire de kill dans le vide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 ElseIf System.IO.Directory.Exists(Environment.SpecialFolder.Desktop & "\Extazy\Config.xml") = False Then My.Computer.Network.DownloadFile("https://www.dropbox.com/s/86436lt21a6m071/config.xml", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Extazy\Config.xml") End If
Mais le problème est que peu importe si le dossier Desktop\Extazy existe, il suit la ligne en considérant qu'il n'existe pas, et me dit qu'il ne peut pas crée le fichier etant donné qu'il existe déja.
Comment puis-je faire ?
Merci d'avance je débute et je n'en sors pas
Partager