Save settings inside the executable?
Is it possible? If yes may someone help me?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sergio FonsecaPosted Feb 7, 2008, 12:38 PM
Scott LyslePosted Feb 7, 2008, 12:36 AM
You can use the property settings to do this easily enough.
1. Open Properties from the solution explorer.
2. Click on the Settings Tab
3. Create a setting. Set the name, type, scope, and value. Scope should be set to user if you want to allow the user to do something that will be saved in the setting. The value can be any default value.
For example, if I want to load a greeting into a label control each time the user fires up the application, I can create a setting called Greeting, of type string, scope it to user, and set the default value to Hello.
To load the greeting, I would use something like this:
label1.Text = Properties.Settings.Default.Greeting;Now, if I add a textbox and a button to the form, I can give the user the means to change the setting.
If the user types into the textbox and clicks the button, I can change the greeting to whatever was typed into the textbox using something like this:
Properties.Settings.Default.Greeting = textBox1.Text; Properties.Settings.Default.Save();