public class ConfigHelper
{
/// <summary>
/// jailall.sun 写错误日志
/// </summary>
/// <param name="message"></param>
public static void ErrorLog(string methodName, Exception ex)
{
string path = Application.StartupPath + "\errorLog\" + DateTime.Now.ToString("yyyMMdd");
FileHelper.AppendText(path, "--------------" + methodName + "--------------");
FileHelper.AppendText(path, "message:" + ex.Message);
FileHelper.AppendText(path, "Source:" + ex.Source);
FileHelper.AppendText(path, "StackTrace:" + ex.StackTrace);
FileHelper.AppendText(path, "TargetSite:" + ex.TargetSite.ToString());
FileHelper.AppendText(path, "");
}
/// <summary>
/// 获取配制信息
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
//public static string GetAppstring(string key)
//{
// try
// {
// string WinConfig = Application.StartupPath + "\Web.config";
// XElement wc = XElement.Load(WinConfig);
// var add = wc.Descendants("add").ToList().Where(c => c.Attribute("key").Value == key).First();
// string str = add.Attribute("value").Value;
// return str;
// }
// catch (Exception ex)
// {
// return ex.Message;
// }
//}
/// <summary>
/// 获取配置值
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string GetConfigStr(string key)
{
try
{
return ConfigurationManager.AppSettings[key];
}
catch (Exception ex)
{
return ex.Message;
}
}
}