vs 2005中类库如何访问 app.config
#region 取得Lib的App.config的连接字符串
try
{
string fileFullPath = Assembly.GetExecutingAssembly().CodeBase.Replace("[url=file:///]file:///", string.Empty);
string filePath = fileFullPath.Substring(0, fileFullPath.LastIndexOf("/")) + "/App.config";
if (document == null)
{
document = new XmlDocument();
}
document.Load(filePath);
connectionString = document.SelectSingleNode(@"/configuration/appSettings/add[@key='connString']").Attributes["value"].Value;
}
catch (XmlException ex)
{
throw new XmlException(ex.Message);
}
#endregion
遇见了就不要错过