c# 读取*.config文件指定节点的值
2013-06-26 14:42
302 查看
以下为config文件中的内容:
<?xml version="1.0" encoding="utf-8"?>
<FileBaseDir xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<BaseDir>/Temp/HeLiuDistFile/</BaseDir>
</FileBaseDir>
c#代码中解析的方式:
XmlDocument xmlDoc = new XmlDocument();
string appStartupPath = System.AppDomain.CurrentDomain.BaseDirectory;
xmlDoc.Load(appStartupPath + @"ConfigurationFiles\ConfigPath\TestConfig.config");//获取配置文件存放的位置
XmlNode root = xmlDoc.SelectSingleNode("FileBaseDir");
if (root != null)
{
m_DistFileBaseDir = root.SelectSingleNode("BaseDir").InnerText;
}
<?xml version="1.0" encoding="utf-8"?>
<FileBaseDir xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<BaseDir>/Temp/HeLiuDistFile/</BaseDir>
</FileBaseDir>
c#代码中解析的方式:
XmlDocument xmlDoc = new XmlDocument();
string appStartupPath = System.AppDomain.CurrentDomain.BaseDirectory;
xmlDoc.Load(appStartupPath + @"ConfigurationFiles\ConfigPath\TestConfig.config");//获取配置文件存放的位置
XmlNode root = xmlDoc.SelectSingleNode("FileBaseDir");
if (root != null)
{
m_DistFileBaseDir = root.SelectSingleNode("BaseDir").InnerText;
}
相关文章推荐
- C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案
- C#指定config配置文件读取信息
- C#读取指定目录下的config文件
- C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案
- C# config配置文件 自定义节点读取
- C# 读取app.config配置文件 节点键值,提示 "配置系统未能初始化" 错误的解决方案
- C# 读取和修改指定config文件内的配置
- C# 读取app.config配置文件 节点键值,提示 "System.TypeInitializationException 类型初始值设定项引发异常" 错误的解决方案
- C#读取指定文件夹中的所有文件
- C#中怎样读取xml文件中节点的值
- C#读取文件内容,在指定行插入内容
- C#中读取xml文件指定节点
- c#读取app。config文件到下拉列表
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法 (转)
- C# winForm读取配置文件 App.config
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法
- C# 从内嵌资源读取文件内容并写入到指定位置
- C#读取app.config配置文件中的connectionString节点
- C#中读取“已注册的文件类型”的图标及读取指定文件图标的方法
- Web.config文件中节点的配置数值读取的2种方法,哪种更快?