I have a .NET Framework app, and I need to save and load the state of bool variable. I tried to do this, using MyApp.Properties library. Here my code for save:
private static void ChangeBoolState()
{
warningMessageState = false;
Settings.Default["warningMessageState"] = warningMessageState;
Settings.Default.Save();
}
And here for load:
warningMessageState = Convert.ToBoolean(Settings.Default["warningMessageState"]);
When I try to load or to save this variable using this code, I get the error:
System.Configuration.SettingsPropertyNotFoundException: "Settings property 'warningMessageState' could not be found."
Anybody know, what am I doing wrong? Thank You in advance!
Properties.Settings.Default.WarningMessageState = true;
Properties.Settings.Default.Save();
if(Properties.Settings.Default.WarningMessageState)
MessageBox.Show("Warning!");