Bonjour à tous !
Voici mon problème :
Mon logiciel à besoin de sauvegarder des informations dans un fichier .ini et de les lires au lancement du logiciel.
Voici mon code pour écrire :
Tout les mot commencant par "cle" sont des constantes string.
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 Sub writeini(ByVal Timesave As String, ByVal Hsave As String, ByVal Msave As String, ByVal pathsave1 As String, ByVal pathsave2 As String, ByVal ShowNotify As Boolean, ByVal autosave As Boolean) Nbrligneini = 0 Dim sw As New StreamWriter(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData + "\CONFIG.ini") sw.WriteLine(";Fichier de configuration de FileSecur") sw.WriteLine("[Configuration]") sw.WriteLine(cletimesave + "=" + Timesave) sw.WriteLine(cleHoursave + "=" + Hsave) sw.WriteLine(cleMinsave + "=" + Msave) sw.WriteLine(clepathsaveini1 + "=" + pathsave1) sw.WriteLine(clepathsaveini2 + "=" + pathsave2) sw.WriteLine(cleShowNotify + "=" + ShowNotify.ToString) sw.WriteLine(cleautosave + "=" + autosave.ToString) sw.WriteLine("Nbrligne=" + ListBox1.Items.Count.ToString) sw.WriteLine("[Paths]") For Each item In ListBox1.Items Nbrligneini += 1 sw.WriteLine(clepathini + Nbrligneini.ToString + "=" + item) Next sw.Close() End Sub
J'obient un fichier .ini comme celui ci :
Il y a autant de Paths dans la clause [Paths] que d'éléments dans une listbox sur le formulaire.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 ;Fichier de configuration de FileSecur [Configuration] Timesave=11/09/2016 17:32:19 Hsave=1 Msave=0 save1= (chemin du dossier de destination) save2= ShowNotify=True AutoSave=False Nbrligne= (nombre de path) [Paths] Path1= (chemin dossier source) Path2= (chemin dossier source)
Le probleme est a la lecture :
En effet, le fichier est bien lu et tout les élément sont dans ma form (date...) sauf les paths ! je ne sais pas pourquoi il refuse de m'ajouter pour chaque paths dans le fichier, le paths dans ma listbox...
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 Sub readini() Nbrligneini = 0 For Each Ligne As String In File.ReadAllLines(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData + "\CONFIG.ini" + "") Nbrligneini += 1 Select Case Ligne.Split("=")(0) Case cletimesave TextBox1.Text = Ligne.Split("=")(1) Case cleHoursave NumericUpDown1.Value = CInt(Ligne.Split("=")(1)) Case cleMinsave NumericUpDown2.Value = CInt(Ligne.Split("=")(1)) Case clepathsaveini1 TextBox2.Text = Ligne.Split("=")(1) Case clepathsaveini2 TextBox3.Text = Ligne.Split("=")(1) Case cleShowNotify ShowNotify = Ligne.Split("=")(1) Case cleautosave Autosave = Ligne.Split("=")(1) Case nbrligne Nbrligneini = CInt(Ligne.Split("=")(1)) Case clepathini + Nbrligneini.ToString ListBox1.Items.Add(Ligne.Split("=")(1)) End Select Next End Sub
Merci de votre aide !
Ind6x
Partager