here is an example of how to save some value from a textbox text value to your config file
Main Topics
Browse All TopicsI've been reading all sort of questions about writing to the app.config file and yet have not found a good answer that will show me how to accomplish that. I am usinf framework 3.5 and visual studio 2008 and I need to change some values in my config file through a windows form. I don't want to creat another xml file. is there a way to save to the app.config file?
thanks a lot
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
thank you guys for your reply,
p_davis, when i am trying to assign value to kvcs.Vaue i get the following error:
"Object reference not set to an instance of an object." and i create the line above it, which allows me to retrieve value from my config file just fine, so it must have been initialized, i don't know why i am getting this error.
the following line worked for me:
txtSomeTextBoxValue.Text = config.AppSettings.Setting
PS:
in your code:
kvce.value = txtSomeTextBoxValue.Text;
how does the kvce value know to which appSetting variable will it save to? I mean my appSetting will have something like:
AppSettings.Settings["some
AppSettings.Settings["some
AppSettings.Settings["some
and you say: kvce.value = txtSomeTextBoxValue.Text;
will you be assign the kvce value to someKeyVariable1 or someKeyVariable2 or ..etc
thank you for your help
I am raising the points to 250
thanks davis, we are almost there,
two questions:
1- I guess when in run mode the app file becomes app.exe.config and when in solution its app.config? is that why the results show only in app.exe.config?
2- if i have more than one AppSettings variable should i create the following:
kvce1 = config.AppSettings.Setting
kvce2 = config.AppSettings.Setting
... etc ?
thanks again
Business Accounts
Answer for Membership
by: jaime_olivaresPosted on 2008-03-30 at 11:27:33ID: 21241472
config file is saved automatically, just you have to edit the "settings" variables.
t.varnameh ere
in your solution explorer, look at the Properties node, then dobule click the "settings.settings" node.
Insert variables there, there are 2 kind of "scopes" for each variable.
Aplication scope define readonly variables
User scope define read/write variables.
Both will be stored automatically.
To read or write a setting variable, use something like:
Properties.Settings.Defaul