Bonsoir,
Je butte depuis trop longtemps alors je viens demander de l'aide ici
J'ai un fichier app.config et j'ai créé une classe pour gérer le fichier.
Ma classe arrive bien à lire les données mais je n'arrive pas à enregistrer les nouvelles.
Voici ma classe :
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 public class App_Config { public Configuration Config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); public App_Config() { } public string Level { get { return Config.AppSettings.Settings["Level"].Value; } set { Config.AppSettings.Settings["Level"].Value = value; } } public string Player1 { get { return Config.AppSettings.Settings["Player1"].Value; } set { Config.AppSettings.Settings["Player1"].Value = value; } } public string Player2 { get { return Config.AppSettings.Settings["Player2"].Value; } set { Config.AppSettings.Settings["Player2"].Value = value; } } public string Sound { get { return Config.AppSettings.Settings["Sound"].Value; } set { Config.AppSettings.Settings["Sound"].Value = value; } } public void Save_config() { Config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("AppSettings"); } }
Merci de m'aider à enregistrer les changements![]()
Partager