Config.xml file read and write ?

  • Thread starter Thread starter MrXs
  • Start date Start date
M

MrXs

i have a setting form for my program and wish to allow the setting to
be saved and reopened to the last set setting on program startup..


lets say i have a xml file like this :



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="test" value="My Test String"
/>
</appSettings>
</configuration>



[code:1:9a6bbbbeac]

private void button1_Click(object sender, System.EventArgs e)
{

//here i put what code ??

}

[/code:1:9a6bbbbeac]

how do a get the app to save any new settings to this xml file and
also how do i load the setting on program startup ?

Thanks

MrXs
 
In your config file,specify the name of a seperate settings file (or use a
default name). If the app is run by multiple users, and they each need
their own settings, make sure you store the settings file in their local
"Documents and Settings" folder, and not in the app directory.

Have your app deserialize the setting file when you start up, and
reserialize it when you shut down. XML of course.

Let the config file be application config, not user settings. Most .NET
apps do this or a form of this for storing settings, rather than changing
the config file itself.

--- Nick
 
Back
Top