write to app.config file

D

dale

I am trying store and update some variables/options that
the user can set and that need to be saved and used each
time the program is run. I am thinking that they should
be stored in the app.config file and also changed there
when the user modifies these options.

My question is does this sound right and is there a
variable that will give me the path to the app.config
file?

Thanks in advance.
 
C

Cor

Hi Dale,

I think that for what you ask are two nice sollutions,
Make your own "config" XML file using a XML dataset
or
The registry
Both is very easy to do with VB.net

I hope this helps,

Cor

"> I am trying store and update some variables/options that
 
C

Codemonkey

I am thinking that they should
be stored in the app.config file and also changed there
when the user modifies these options.

AFAIK, the App.config file is used to store settings that only the
administrator has access to and therefore should not be written to by the
applicatin directly. Also, if you write settings to this file, the settings
will be global to the machine, not local to the specific user.

Alternatives include:

Writing to the registry
Writing to an ini or xml file which is stored in the "ApplicationData"
special folder
Use Isolated Storage

Hope this helps,

Trev.
 
W

William Ryan

This is an example on how to create keys and get their values from an
app.config file http://www.knowdotnet.com/articles/configfiles.html
However, if you want to edit it, you can't do it programatically, you need
to fire up and editor and do it there.

Cor and Codemonkey are correct and an easy way to do what you want is either
the registry or an XML File. As easy as it is to create serializable
objects in .NET, particulalry with the SOAP formatter for instance, or just
adding values to a DataSet and using the .WriteXML and .ReadXML methods
respectively.

Dan Fergus and Larry Roof wrote a book The Definitive Guide to the Compact
Framework which has a great example of it (the CF has not native access to
the registry and doesn't support .config files)...

HTH,

Bill
 
H

Herfried K. Wagner [MVP]

* "dale said:
I am trying store and update some variables/options that
the user can set and that need to be saved and used each
time the program is run. I am thinking that they should
be stored in the app.config file and also changed there
when the user modifies these options.

Storing "user preferences" is not the purpose of config files.

Configuration Management Application Block
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/cmab.asp>

<http://www.palmbytes.de/content/dotnetlibs/optionslib.htm>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top