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

App.Config - Read and Save

P: n/a
Looking back in the group, I figured out how to read from the appSettings
section of the configuration file.

I have default values for the application in the unlikely event that the
user deletes the configuration file. My question is this: How do I write the
defaults back out to the configuration file at run time? is this even
possible?

I understand that the System.Configuration API is read only so would I
basically have to read in the configuration file in total, create the XML
file (including the missing values) and write it back out using the normal
system.io ?

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

P: n/a
You might look at the Enterprise Library and it's configuration
application block. It's very flexible and allows for reading and
writing.

In response to your question, you could use the System.Xml namespace to
read and write values to the app.config file.

Nov 21 '05 #2

P: n/a
see
http://www.west-wind.com/presentatio...ationclass.asp

--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)

"Stephen Costanzo" <sx********@hotmail.com> wrote in message
news:Oj**************@tk2msftngp13.phx.gbl...
Looking back in the group, I figured out how to read from the appSettings
section of the configuration file.

I have default values for the application in the unlikely event that the
user deletes the configuration file. My question is this: How do I write
the
defaults back out to the configuration file at run time? is this even
possible?

I understand that the System.Configuration API is read only so would I
basically have to read in the configuration file in total, create the XML
file (including the missing values) and write it back out using the normal
system.io ?

Thanks

Nov 21 '05 #3

P: n/a
Stephen Costanzo wrote:
Looking back in the group, I figured out how to read from the
appSettings section of the configuration file.

I have default values for the application in the unlikely event that
the user deletes the configuration file. My question is this: How do
I write the defaults back out to the configuration file at run time?
is this even possible?

I understand that the System.Configuration API is read only so would I
basically have to read in the configuration file in total, create the
XML file (including the missing values) and write it back out using
the normal system.io ?

Thanks


E-mail me (tierscheiss1977 on Hotmail) and I'll send you a custom
library I made that allows Read/Write functionality to the appSettings
and userSettings section of the App.Config/Web.Config file. I use it
in all my projects that require me to use a .Config file.

maybe, when I get some time, I'll make an article on it on codeProject

Tibby
Nov 21 '05 #4

P: n/a
"Chris Dunaway" <du******@gmail.com> wrote in news:1122917801.219032.193180
@o13g2000cwo.googlegroups.com:
In response to your question, you could use the System.Xml namespace to
read and write values to the app.config file.


Using System.XML is a good approach, but you should not write to app.config. Read the blogs on
MSDN and the comments in the footer of this article:
http://www.codeproject.com/dotnet/XMLSettingsFile.asp
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
Nov 21 '05 #5

P: n/a
"Stephen Costanzo" <sx********@hotmail.com> wrote in
news:Oj**************@tk2msftngp13.phx.gbl:
Looking back in the group, I figured out how to read from the
appSettings section of the configuration file.


appSettings is not designed to be read/write and you should not write to it.

You might be interested in this:
http://www.codeproject.com/dotnet/XMLSettingsFile.asp
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.