Before the .NET Framework application settings were saved in INI files and the Windows Registry. But the .NET Framework introduced a much easier way using an XML file. The file has the name of the Assembly and a .exe.config extension, and is placed inside the application’s folder. This way is cleaner because when an application is uninstalled or deleted the end user does not have to worry about left over registry keys or INI files in the Windows directory.
Each setting has four properties: name, type, value, and scope. The type can be a data type or an object. The scope can be user or application. The main difference between them is settings with application scope are read only at run time, while settings with user scope are read/write at run time.
Creating a New Settings
To start creating new settings, from the Solution Explorer right-click on the project node and select Properties, or expand the Properties node and double-click the .setting file. And then enter the name, type, scope and value for each setting.

Manipulating the Settings
To read and save the value of a setting in C# use the Properties object. The following example uses a TextBox and 2 Buttons named newValueTextBox, displayButton and saveButton respectively.
private void displayButton_Click(object sender, EventArgs e)
{
//get the value of SavedSetting1 which is a string
string currentVal = Properties.Settings.Default.SavedSetting1;
MessageBox.Show("The value of SavedSetting1 is '" + currentVal + "'");
}
private void saveButton_Click(object sender, EventArgs e)
{
//set the new value of SavedSetting1
Properties.Settings.Default.SavedSetting1 = newValueTextBox.Text;
//apply the changes to the settings file
Properties.Settings.Default.Save();
}






Hello
When I use this row
Properties.Settings.Default.SQLFormsTestConnectionString = tbConnectionString.Text;
I get compiler error.
Inventory.Properties.Settings.SQLFormsTestConnectionString’ cannot be assigned to — it is read only
So… what is your solution to this and it seams that there is none.
Hello Nisse,
Could you give me some more details like, did you create SQLFormsTestConnectionString using the Settings tab and what is the scope?
I get cannot be assigned to — it is read only trying to assign to a setting. this doesn’t work. application scope.
It seems like both of you are getting the same error, you are trying to assign a value to a setting that has an application scope. Settings with application scope are meant for things like connection strings, which the user cannot change at run time.
So if that’s the case just delete the setting and create a new one with the same name and change the scope to User. That should solve it.
I am not very happy that people keep saying things like Change Application Settings, when in fact they are not showing how to change application settings.. They are showing how to change User Settings at run time. I did not find this helpful at all.