473,480 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

App.Config - Read and Save

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
5 1662
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
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
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
"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3808
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply*...
2
436
by: Tim Blizard | last post by:
I know this topic has been discussed before but I couldn't find any thread more recent than about 18 months and was interested in what conclusions people had come to recently. Invariably 3...
1
5302
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; ...
8
2328
by: vadim | last post by:
Hi, Is there a .Net control available that allows to write into web.config file appsettings section? The idea is to create encrypted user name and password for database connection and then...
17
3221
by: Fred Nelson | last post by:
Hi: I have written several web applications that obtain their connection strings from the web.config file. This is very easy to use and it makes it easy to move an app from development into...
4
2749
by: keithb | last post by:
How can an application change settings in the web.config file? I need to allow users to configure SMTP email settings with functionality similar to that provided developers by the ASP.NET Web Site...
10
9411
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a...
0
2200
by: vikramp | last post by:
Hi, I am storing theme in web.config using <pages theme="mytheme"/>. I am then using the following code to read it from my webpage: Configuration config =...
2
7274
by: Bragadiru | last post by:
Hi all, I want to add a new connection string to my webservice web.config file at runtime : ConnectionStringSettings connStringsSettings = new...
8
16081
by: Andrus | last post by:
..NET 2 Winforms application. How to create new setting and set it default value in userSettings section of app.config file or overwrite existing setting value ? I found code below in this list...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7081
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5336
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4776
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.