using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; namespace DM_Weight.util { internal class ReadApp { //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题 public static string ReadAppSetting(string key) { string xPath = "/configuration/appSettings//add[@key='" + key + "']"; XmlDocument doc = new XmlDocument(); string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; doc.Load(exeFileName + ".dll.config"); XmlNode node = doc.SelectSingleNode(xPath); return node.Attributes["value"].Value.ToString(); } } }