simple question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have forgotten how to write that simple thing:
I have app.exe.config file with my custom section where I initialize a
variable used then in application. User can chande a value of this variable
so I would like to save it in the app.exe.config file. when user starts the
application next time , the vatriable should initialize with lately saved
value
How to do that? Thanks

App.exe.config example:


<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="UMA.NET"
type="System.Configuration.SingleTagSectionHandler" />
</configSections>
<UMA.NET func="3" B1Hi="0" B1Lo="0" B2Hi="0" B2Lo="31" CRC1="0" CRC2="0" />
</configuration>
 
Damar

You normally would use
System.Configuration.ConfigurationSettings.GetConfg(string sectionName)
static method, this will return a Hashtable with your key / value
combination.

HTH
Jako
 
I dont like to read (I can, of course) but save the variable to
app.exe.config from ma application
 
Sorry, I misundertsood your question. I don't think the framework provides
standard functionality to write to config file, only to read from them.

I might be wrong here, but it seems like you'll have to write your own code
to change the values in the config file (using stream readers and writers).
 
Jako is correct.
If you need to add a new option to your config section, or modify an
existing one,
you need to rewrite the whole file.

F.O.R.
 
Back
Top