C#创建日志方法
程序员文章站
2022-06-20 08:45:07
1.通过流的方式 1 public void WriteLog(string log) 2 { 3 StreamWriter stream; 4 string path = "D:/WriteLog/"; 5 if (!Directory.Exists(path)) 6 { 7 Directory. ......
1.通过流的方式
1 public void writelog(string log) 2 { 3 streamwriter stream; 4 string path = "d:/writelog/"; 5 if (!directory.exists(path)) 6 { 7 directory.createdirectory(path); 8 } 9 stream = new streamwriter(path + "addvideo.txt", true, encoding.utf8); 10 stream.writeline(datetime.now.tostring() + ":" + log); 11 stream.flush(); 12 stream.close(); 13 }