您的位置:首页 > 其它

XML文件简单操作

2008-08-19 14:57 471 查看
1读取XML文件

using System.Xml;

public static string GetAppSetting(string appSettingName)

{

XmlDocument _settings = new XmlDocument();

string FileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\我的应用程序.exe.config";

StreamReader _sr = new StreamReader(FileName);

_settings.Load(_sr);

_sr.Close();

foreach (XmlNode node in _settings["configuration"]["appSettings"])

{

if (string.Compare(appSettingName, node.Attributes["key"].Value) == 0)

{

return node.Attributes["value"].Value;

}

}

return "";

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: