Bear in mind that users don't necessarily have write access to this
area.  Only administrators or power users are able to write to the
directory in which the application is installed.  So if the end user is
not running as an administrator, attempting to write settings into the
application config file will fail.

Also, bear in mind that a simple ordinary desktop PC (or laptop) running
Windows may still be multi-user.  Multi-user doesn't mean terminal
server. Different people (e.g. different family members) may log in at
different times.  So there are very few scenarios where you can really
assume that a machine is genuinely 'single-user'.

Also, bear in mind that if someone is using a domain account, they may
have an account configured with a roaming profile, meaning they want
their settings to follow them from one machine to another.  This
definitely won't work if you store settings in the application config
file.

Also, bear in mind that depending on how your application is deployed,
the application config file might not even be on the end user's machine.
It is possible to deploy a windows forms application via a web server or
a file server. In both cases, multiple users all download the EXE and
the config file from the same place, so you really can't store per-user
settings in the config file.

In summary, the application config file is only user-specific in
specific scenarios. (Excluding many scenarios where each user has his or
her own machine.) And it is only writable in a subset of those
scenarios.

Windows has a whole mechanism designed specifically to deal with what
you're trying to do. The profile directory, and the conventions for
where to store things in it are all there so that you can store per-user
settings.  Why would you try and use the app.config file when there are
so many problems with it, and when a much better mechanism is available?


-- 
Ian Griffiths - DevelopMentor
http://www.interact-sw.co.uk/iangblog/

> -----Original Message-----
> From: Clark, Michael (OFM)
> 
> That makes sense.  However, the config file for a winforms app on a
> single-user machine would be user-specific.
> 
> -----Original Message-----
> From: Chris Anderson (Merak) [mailto:[EMAIL PROTECTED]
> 
> The application/web config is not in a folder that normal (non-admin)
> users
> should have read/write access to. (ie it's with the application in
Program
> Files / wwwroot)
> This is why the Framework only supplies read-only functionality.
> 
> You need to look into storing data in user-accessible areas (HKCU in
> registry, a database, isolated storage, etc)
> Remember that if you did write the code to allow updates to the
app/web
> config file, that it would not be user-specific anyway.
> 
> Merak
> 
> > I've been looking to see how I would go about maintaining a
> > .config file using some functionality of the
> > System.Configuration class, but all it seems to be able to do
> > is read the web.config or app.config files and report the contents.
> >
> > But what if you want to retain user-configurable settings in
> > a .config file (without asking the user to mess with the
> > configuration file directly)?  I know it has to be do-able,
> > but I can't seem to find any documents about it.
> >
> > Or do I have to read the .config file as an xml file into an
> > XmlDocument and manipulate it that way?  It would be nice if
> > there was a simpler way.

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

Essential .NET: building applications and components with CSharp
August 30 - September 3, in Los Angeles
http://www.develop.com/courses/edotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to