473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

write to app.config file

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.

Nov 20 '05 #1
4 6033
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
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?

Nov 20 '05 #2
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.

"dale" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl... 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.

Nov 20 '05 #3
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
"dale" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
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.

Nov 20 '05 #4
* "dale" <an*******@discussions.microsoft.com> scripsit:
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>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
33
by: Nick Evans | last post by:
Hello there, I have been on and off learning to code (with python being the second language I have worked on after a bit of BASIC). What I really want to know is, if you are going to actually...
0
by: Joan Bos | last post by:
Hi, Is there somewhere on the Internet a description of what a .NET application config file should contain? For our application, I have to write passwords encrypted in a config file. The...
2
by: Shaun Ram | last post by:
Hi I have this constraint. A help would be greatly apprecitated. I have this Config file. <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <sectionGroup name="ITASCA">...
9
by: ALI-R | last post by:
Hi,, I have two questions : 1) Is it mandatory that config file of a desktop application must be App.config 2) Is it possible to update config file in your code?? thanks for your help. ALI
4
by: feng | last post by:
..Net's .config file is supposed to replace the .ini files. That's all fine if all I need is to read from it. But what if I need both read and write? With .ini file, I can do that very easily with...
3
by: Agnes | last post by:
Can I write a file like config.ini which store the server-name, userid & password, So, my application can read the config.ini file and get the server - name, Does my concept is correct ? If...
4
by: Jeff smith | last post by:
I am reading the value from config file using the below statement. System.Configuration.ConfigurationSettings.AppSettings("MY_DATA") How to write data back to the same location? I am using...
1
by: Lialie | last post by:
Hello,all I found it easy to read configures from a config file. But how can I set a special value to an item or write it into the original file? I have tried this: import ConfigParser config...
4
by: apriebe47 | last post by:
Alright, I realize this is probably very basic to be posted on this newsgroup but I cannot figure out what is causing my problem. Here is the code I am using below: from getpass import getpass ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.