XML config write

kejpa

Well-known member
Joined
Oct 10, 2003
Messages
320
Hi,
all you hear of is how terrific XML is. I must admit that Im not all convinced, so you better show me how simple it is ;)

I have a file (config-file actually) where I want to change a value from 15 to 31. With the ancient old ini files you could just say what section and key and it was all done. How do you do it with the new fancy xml config files?
The node I want to change is...
/configuration/system.diagnostics/switches/add
and there are a few with the same name but with different "name" attribute

Looking forward to the simplicity of XML...
/Kejpa
 
You should look into the application blocks for Configuration Management that Microsoft published a while back - here

Even if you dont want to add all this into your project, you can see how they handled writing information back to XML config files and update that code as you see fit.
 
While VS 2003 provides an easy way to retrieve config file settings (ConfigurationSettings), it currently gives us no way to write back to the .config file. Too bad, maybe in 2005?

Some people have written their own stuff to write to config files, heres one example.

FWIW, Ive started to get away from a single config file for the application, because many users may be using the same machine and want different settings. So what Ive done is make an object that holds all the settings, then serialize/desialize to xml. So the application will use the .config for the particular user.
 
The general idea of web.config / app.config files are for basic administrative changes (connectin strings, urls etc.), rather than day to day settings - in fact on XP & 2003 Server a normal user will not have permissions to write to the programs fol.
For per user / per machine settings you may be better of using serialisation to store them either under the PCs profile director or within IsolatedStorage.
 
PlausiblyDamp said:
The general idea of web.config / app.config files are for basic administrative changes (connection strings, urls etc.), rather than day to day settings
In fact, this is a administrative setting I have in my mind.
I want to change the level of my trace objects for the next session. So I guess Im stuck with the App.config file

And its a one user machine (or better put, one user account) so I dont need to bother about multiuser wishes and settings...

mhildner said:
While VS 2003 provides an easy way to retrieve config file settings (ConfigurationSettings), it currently gives us no way to write back to the .config file. Too bad, maybe in 2005?
VB3 from mid 90s (how old it sounds...) had functionallity to write settings, seems more and more to me that VS2002/2003 are merely .NET v 0.1 than 1.0.
Lets hope VS2005 can write settings as well.

/Kejpa
 
Back
Top