c# - Why isnt Properties.Settings.Default being saved? -
I wrote to test quickly
Why is my settings not being saved? For the first time I have 3 (old) / 3 (current) elements to run it. Second time I get 3 (old) / 5 (current), 5 times for the third time (old) / 5 (current).
When I close the app, the settings completely disappear. Its 3 again when i run it I did not make any changes to the app. Why not saving my settings
Private Zero Button 2_Click (Object Sender, EventArgs e) {MyApp.Properties.Settings.Default.Reload (); Var saveDataold = MyApp.Properties.Settings.Default.Context; Var saveData = MyApp.Properties.Settings.Default.Context; SaveData ["user"] = textbox1.Text; SaveData ["pass"] = textbox2.Text; MyApp.Properties.Settings.Default.Save (); Instead of putting your data in context, you should use highlighted properties:
var saveData = MyApp.Properties.Settings.Default; SaveData.user = textBox1.Text; SaveData.pass = textbox2.Text;
The reference
provides relevant information that the provider can use at the time of presentation
and my Understand that actual setting values are not used to store.
Update: If you do not want to use the settings editor in Visual Studio to generate visual-type properties, then you can code it yourself. The code generated by VS has such a structure: [user Skype setting] [debugger NOUScorcode] [default setting value ("")] public string setting name {{{return (string) (this ["Setting name"])); } Set {this ["SettingName"] = value; }}
You can easily add more assets by editing the settings. Designer.cs file
If you do not want to use strong-typed properties, you can use the this [name]
index directly. Then your example will look like this:
var saveData = MyApp.Properties.Settings.Default; SaveData ["user"] = textbox1.Text; SaveData ["pass"] = textbox2.Text;
Comments
Post a Comment