首页 > 其他 > 详细

写日志

时间:2017-08-17 22:31:15      阅读:270      评论:0      收藏:0      [点我收藏+]

public static void writeLog(string strContent)
{
string strPath = "c:\\importorderlog";
string strFileName = DateTime.Now.ToString("yyyyMMdd") + ".txt";
System.IO.FileStream fs = null;

if (!System.IO.Directory.Exists(strPath))
{
System.IO.Directory.CreateDirectory(strPath);
}
if (!System.IO.File.Exists(strPath + "\\" + strFileName))
{
fs = System.IO.File.Create(strPath + "\\" + strFileName);
}
if (fs == null)
fs = new System.IO.FileStream(strPath + "\\" + strFileName, System.IO.FileMode.Append);
System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
sw.WriteLine(strContent);
sw.Close();
sw.Dispose();
}

写日志

原文:http://www.cnblogs.com/zhang-wenbin/p/7384606.html

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