By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

Can app.config be updated by the user?

P: n/a
I store several application settings in the project's "app.config" file. I
also have a form that reads these values and displays them in a listview so
that the user can adjust them. My question is: can the changes made by the
user to the settings values be saved back to "app.config" so that when the
application is launched tomorrow, the updated values are used?

Since the original app.config settings are loaded to
"projectName.exe.config", and updated there by the user, another way of
asking the same question is: how to write the values in
"projectName.exe.config" back to "app.config"?

Thanks,
Dean Slindee
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Dean Slindee" <sl*****@charter.net> wrote in
news:10*************@corp.supernews.com:
My question is: can the changes made by the
user to the settings values be saved back to "app.config" so that when
the application is launched tomorrow, the updated values are used?


No, the config files are read only, You'll need to write your own XML
classes to update the configs.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2

P: n/a
Microsoft 'prefers' that the app.config file be considered a read-only
application initialization repository. For one thing, since there's only one
file for the application it's machine-wide rather than user-specific. Thus
it's not a good place for user-specific preferences. Probably the best place
to store user preferences is in your own XML files, either in user-specific
isolated storage, or in the directory represented by
Application.UserAppDataPath.

Quite a few people, by now, have created libraries for managing user
preferences in XML files (I've certainly done it for my own personal use).
It's a shame that MS didn't supply wrapper classes for this in the
framework, since we're all having to re-invent the wheel on this. If you
look around places like www.gotdotnet.com or www.sourceforge.net you'll
undoubtedly come across one or more solutions to this problem that have been
contributed by that community. I haven't contributed my own, since I doubt
that the world needs another one.

Tom Dacon
Dacon Software Consulting

"Dean Slindee" <sl*****@charter.net> wrote in message
news:10*************@corp.supernews.com...
I store several application settings in the project's "app.config" file. I also have a form that reads these values and displays them in a listview so that the user can adjust them. My question is: can the changes made by the user to the settings values be saved back to "app.config" so that when the
application is launched tomorrow, the updated values are used?

Since the original app.config settings are loaded to
"projectName.exe.config", and updated there by the user, another way of
asking the same question is: how to write the values in
"projectName.exe.config" back to "app.config"?

Thanks,
Dean Slindee

Nov 21 '05 #3

P: n/a
I should also add, as a disadvantage of trying to write into the app.config
file, that you can't guarantee that the user of the application will have
write permissions on the directory in which the application executable and
the config file reside. A system administrator might lock that directory
down, causing your application to fail with a permissions exception when you
tried to write to the file.

Tom Dacon

"Tom Dacon" <td****@community.nospam> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Microsoft 'prefers' that the app.config file be considered a read-only
application initialization repository. For one thing, since there's only one file for the application it's machine-wide rather than user-specific. Thus
it's not a good place for user-specific preferences. Probably the best place to store user preferences is in your own XML files, either in user-specific isolated storage, or in the directory represented by
Application.UserAppDataPath.

Quite a few people, by now, have created libraries for managing user
preferences in XML files (I've certainly done it for my own personal use).
It's a shame that MS didn't supply wrapper classes for this in the
framework, since we're all having to re-invent the wheel on this. If you
look around places like www.gotdotnet.com or www.sourceforge.net you'll
undoubtedly come across one or more solutions to this problem that have been contributed by that community. I haven't contributed my own, since I doubt
that the world needs another one.

Tom Dacon
Dacon Software Consulting

"Dean Slindee" <sl*****@charter.net> wrote in message
news:10*************@corp.supernews.com...
I store several application settings in the project's "app.config" file.

I
also have a form that reads these values and displays them in a listview

so
that the user can adjust them. My question is: can the changes made by

the
user to the settings values be saved back to "app.config" so that when the application is launched tomorrow, the updated values are used?

Since the original app.config settings are loaded to
"projectName.exe.config", and updated there by the user, another way of
asking the same question is: how to write the values in
"projectName.exe.config" back to "app.config"?

Thanks,
Dean Slindee


Nov 21 '05 #4

P: n/a
TO write settings via an xml file:

http://www.kjmsolutions.com/xmlsettings.htm

To write settings to an app.config file....(not recommended)

http://www.kjmsolutions.com/download...onfigstuff.ZIP

to use Isolated storage..(must have adequate .NET permissions..)

http://www.kjmsolutions.com/download...igsystemio.ZIP

________________________________

From: Dean Slindee [mailto:sl*****@charter.net]
Sent: Saturday, August 21, 2004 11:20 PM
To: microsoft.public.dotnet.languages.vb
Subject: Can app.config be updated by the user?

I store several application settings in the project's "app.config" file.
I
also have a form that reads these values and displays them in a listview
so
that the user can adjust them. My question is: can the changes made by
the
user to the settings values be saved back to "app.config" so that when
the
application is launched tomorrow, the updated values are used?

Since the original app.config settings are loaded to
"projectName.exe.config", and updated there by the user, another way of
asking the same question is: how to write the values in
"projectName.exe.config" back to "app.config"?

Thanks,
Dean Slindee
Nov 21 '05 #5

P: n/a
No but see this other app settings class:
http://www.west-wind.com/presentatio...ationclass.asp

--

HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"Dean Slindee" <sl*****@charter.net> wrote in message
news:10*************@corp.supernews.com...
I store several application settings in the project's "app.config" file. I also have a form that reads these values and displays them in a listview so that the user can adjust them. My question is: can the changes made by the user to the settings values be saved back to "app.config" so that when the
application is launched tomorrow, the updated values are used?

Since the original app.config settings are loaded to
"projectName.exe.config", and updated there by the user, another way of
asking the same question is: how to write the values in
"projectName.exe.config" back to "app.config"?

Thanks,
Dean Slindee

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.