If I use the configuration manager and I add a user config then I add a
textbox
and use the application properties and link it to the setting it works fine
when the project loads.
BUT if the user changes the text box to some different text the config
manager doesn't save it automatically
to the config file so the next time the project loads it should have the new
value?
How is this suppose to work?
-Lou
This line of code gives me an error that configuration files are read only
VS2008
ConfigurationManager.AppSettings.Add(strKey, strValue);
Yes, because they are readonly (or rather, write is denied to them).
Static AppSettings property gives you the _default_ app configuration
- which is *.exe.config file for your executable. Since that is
normally somewhere in Program Files, it's read-only for normal users,
as it should be. Use ConfigurationManager.OpenExeConfiguration() with
the appropriate ConfigurationUserLevel to get the user-specific
config, which is writable by that user.
Or just use the Settings Designer in VS, which will wrap it all for
you. There, you just specify for every property whether you want to
have it app global (and so read-only for users), or per-user.