如何在app.config中的自定义部分添加值? [英] How can I add values to my custom section in app.config?

查看:107
本文介绍了如何在app.config中的自定义部分添加值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望以c#窗口形式实际存储app.config自定义部分中的值,就像基于用户在运行时设置用户选择的那样

 < span class =code-keyword><   guisetting  >  
< 用户名 user = abc >
< backgroundcolor > red < backgroundcolor >
< fontsize > 10 < fontsize >
< textcolor > 黄色< span class =code-keyword><
textcolor >

< 用户名 < span class =code-attribute> user = xyz >
< backgroundcolor > blue
< fontsize < span class =code-keyword>> 13 < fontsize >
< < span class =code-leadattribute> textcolor > brown < textcolor >
< backgroundcolor > < 用户名 >
< guisetting >



i阅读了很多文章,但我没找到确切的将动态值添加到app.config的自定义部分的解决方案。

任何人都可以帮助我。

在此先感谢...



我尝试过:



我知道如何从自定义部分读取值但我不知道如何在运行时添加值

解决方案

这里有清楚而全面的解释: https://msdn.microsoft.com/en-us/library/2tw134k3.aspx



问题是你的问题是你从它的上下文中显示了一些XML片段。我们看不到你真正做了什么。你必须从< configuration> 元素开始显示它,但你可以缩短一些不相关的部分。



另见我对该问题的评论。如果你的意思是只读配置,你必须使用其他文件,而不是标准配置。



-SA

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

<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

解决方案

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


这篇关于如何在app.config中的自定义部分添加值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆