views:

66

answers:

2

I am working on a Windows form application with C#,and it would be really helpful if I could modify a value in "setting.setting" file in the program properties. In fact I want to put connection string for SQL database in this file and get it when needed so I need to change it if the connection changed.

A: 

You can modify the value, then call: Properties.Settings.Default.Save();

Alan
How to modify the value ,an error says that Properties.Settings.Default.connectionstring is read only
3bd
+1  A: 

There are two kinds of Settings: Application-scope and User-scope. You can always change User-scope settings (like in @Alans answer), but changing Application-scope requires admin rights. The basic idea is that App-scope settings are only edited by an Admin (using Notepad or whatever).

Explanation: Settings are stored in \Program Files\App\App.exe.config, and you need to be admin to write in \Program Files (under Vista or restricted XP). User settings are stored in the Users Settings folder, the installed .config only contains the default value.

Henk Holterman