Web应用程序dll获取当前程序集路径问题
public string ConfigFile { get { if (String.IsNullOrEmpty(_configfile)) { //string assemblyFile = System.Reflection.Assembly.GetExecutingAssembly().Location; string assemblyFile = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; _configfile = assemblyFile + ".config"; } return _configfile; } }
GarsonZhang www.infnitee.com
获得config配置信息
/// <summary> /// 获取配置文件的属性 /// </summary> /// <param name="key"></param> /// <returns></returns> public string GetConnectionStringValue(string key) { string value = string.Empty; try { //if (File.Exists(ConfigFile)) { XmlDocument xml = new XmlDocument(); xml.Load(ConfigFile); XmlNode xNode = xml.SelectSingleNode("//connectionStrings"); XmlElement element = (XmlElement)xNode.SelectSingleNode("//add[@name='" + key + "']"); value = element.GetAttribute("connectionString").ToString(); } } catch { } return value; }
GarsonZhang www.infnitee.com
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post 管理员