首页 > Windows开发 > 详细

C#创建日志方法

时间:2020-04-26 21:52:06      阅读:77      评论:0      收藏:0      [点我收藏+]
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         }
View Code

C#创建日志方法

原文:https://www.cnblogs.com/alannever/p/12782011.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!