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/