首页 > 其他 > 详细

保存异常日志txt

时间:2019-05-29 18:46:56      阅读:105      评论:0      收藏:0      [点我收藏+]

 

try

{

//执行的代码

}

catch (Exception em)
{
new ExcInsertFile().SetInsertFile(em.ToString());
}

 

//保存异常日志txt

public void SetInsertFile(String str)
{
FileStream myFs = null;
StreamWriter mySw = null;
try
{
myFs = new FileStream("Log/WSExceptionTing.txt", FileMode.Create);
mySw = new StreamWriter(myFs);
mySw.WriteLine(DateTime.Now.ToString() + ": " + str);
}
catch (Exception exmc)
{
return;
}
finally
{
if (mySw != null)
mySw.Close();
if (myFs != null)
myFs.Close();
}
}

保存异常日志txt

原文:https://www.cnblogs.com/wahahaSunnyy/p/10945400.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!