写日志

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

posted @ 2017-08-17 21:56  恋之呓  阅读(162)  评论(0编辑  收藏  举报