C#写入文本txt

1 string now = DateTime.Now.Date.ToShortDateString();
2                 string todayfile = "D:\\" + now + ".txt";
3                 StreamWriter sw = new StreamWriter(todayfile, true, Encoding.GetEncoding("gb2312"));
4                 string ifo = DateTime.Now.ToString() + i + "\r\n";
5                 ifo += "错误发生时候的sql";
6                 sw.WriteLine(ifo);
7                 sw.Close();

 转自:http://benyer1988.blog.163.com/blog/static/1337308892011221105933584/

posted @ 2013-05-28 10:46  isMethod  阅读(186)  评论(0编辑  收藏  举报