从xml文件中获取值并通过C#窗口应用程序(用户界面)更新xml文件 [英] get value from xml file and update xml file throght the c# window application (user interface)

查看:125
本文介绍了从xml文件中获取值并通过C#窗口应用程序(用户界面)更新xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个setting.xml文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appsettings>
    <add>
      <add key="DataSource" value="sql\\express" />
      <add key="Database" value="sample" />
      <add key="UserName" value="sa" />
      <add key="password" value="sa" />
     
  </appsettings>
</configuration>





如何在c#中的setting.xml文件中从appsetting获取值.如何在setting.xml文件中更新数据库,数据源,用户名,密码





how to get value from the appsetting in setting.xml file in c#.how to update database,data source,username,password in setting.xml file

推荐答案

添加一个参考System.configuration.dll.
然后使用
进行设置
Add a reference to System.configuration.dll.
Then get your setting with
string retVal = System.Configuration.ConfigurationManager.AppSettings[name];


更新:最好使用设置"代替配置文件.


Update: better use "settings" instead of the configuration file.


使用CodeProject搜索引擎...

C#.NET II中的序列化-XML序列化 [ ^ ]

使用XML [使用C#轻松进行XML解析 [使用C#2.0中的通用类型将对象作为XML序列化和反序列化 [ ^ ]
Use the CodeProject search engine...

Serialization in C# .NET II - XML Serialization[^]

Working with XML[^]

Easy XML Parsing in C#[^]

Serialize and Deserialize Objects as XML using Generic Types in C# 2.0[^]


这篇关于从xml文件中获取值并通过C#窗口应用程序(用户界面)更新xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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