c#项目中可以用xml文件存储配置参数

来源:互联网 发布:广东广电网络wifi设置 编辑:程序博客网 时间:2024/06/05 03:00
        try
            {
                if (File.Exists(xmlPath))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(xmlPath);
                    XmlElement xmle = xmlDoc.DocumentElement;//获取根节点;
                    string str = xmle.GetAttribute(name);//查找某参数;
                    return str;
                }
            }
            catch
            {
            }