C#創建日志方法


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM