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 "";
        }
 

相关文章:

  • 2022-01-23
  • 2022-12-23
  • 2021-08-27
  • 2021-10-31
  • 2022-01-05
  • 2021-08-07
  • 2022-12-23
猜你喜欢
  • 2022-02-26
  • 2021-07-22
  • 2021-05-31
  • 2022-12-23
  • 2022-02-09
  • 2021-10-25
  • 2022-01-04
相关资源
相似解决方案