码迷,mamicode.com
首页 > 其他好文 > 详细

写日志

时间:2017-08-17 22:53:39      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:ted   datetime   string   close   append   system   exist   写日志   tor   

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();
}

写日志

标签:ted   datetime   string   close   append   system   exist   写日志   tor   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!