Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to store the value in custom section of app.config pragmatically in c# window form like that based on user at runtime on setting selection of user
XML
<guisetting>
  <username user="abc">
  <backgroundcolor>red<backgroundcolor>
  <fontsize>10<fontsize>
  <textcolor>yellow<textcolor>

  <username user="xyz">
  <backgroundcolor>blue
  <fontsize>13<fontsize>
  <textcolor>brown<textcolor>
  <backgroundcolor><username>
<guisetting>

i read many article but i not found exact solution for adding dynamic value to custom section of app.config.
can any body help me.
Thanks In Advance...

What I have tried:

i know how to read the value from custom section but i don't have an idea about how to add value at runtime
Posted
Updated 13-Jun-16 5:45am
v4
Comments
Sergey Alexandrovich Kryukov 13-Jun-16 11:46am    
What does it mean "dynamic value"? The config file is read-only, do you realize that? Is it fine with you?
If not, you have to use some other file.
—SA
F-ES Sitecore 13-Jun-16 12:07pm    
You don't amend the config files at runtime, if you want to do that put your data in a normal xml file and update it using XmlDocument or whatever other method you prefer.

1 solution

This is clearly and comprehensively explained here: https://msdn.microsoft.com/en-us/library/2tw134k3.aspx.

The problem is your question is that you show some XML fragment out of its context. We cannot see what you have really done. You have to show it starting from the <configuration> element, but you could shorten some irrelevant parts.

See also my comment to the question. If you mean something beyond read-only configuration, you have to use some other file, not standard config.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900