app.config

  • Thread starter Thread starter Matthew Morvant
  • Start date Start date
M

Matthew Morvant

I have an application (Windows Form - C#) that uses a .config file. Is
there an easy way to make the values in this file editable by the user
"inside" the application while the application is running? For example one
of my current values is the interval for a timer, I would like the user to
be able to change that value, and have it remain for the next time the
application is started.
 
By default configuration files are read-only, but whether or not you
can do this depends on the type of application. For Winforms, it's
only a text file, and if it lives on the user's hard drive they
probably have administrative permissions on the share so you can just
open it for file I/O. For Web apps, no can do. The idea is that
configuration files are supposed to be read-only. I'd recommend using
isolated storage in a Winforms app for settings you want the user to
be able to edit at runtime. See the help file for more info.

--Mary
 
I have an application (Windows Form - C#) that uses a .config file. Is
there an easy way to make the values in this file editable by the user
"inside" the application while the application is running?

No, by design this is NOT possible, and should be left that way. If
you need to store per-machine or per-user settings, use your own
settings file or the registry.

See:
IanG on Tap: Why Writing Into .NET Application Configuration File Is A
Bad Idea
http://www.interact-sw.co.uk/iangblog/2004/11/25/savingconfig

Marc
 
Back
Top