12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using System.IO;
- using System.Windows.Forms;
- namespace StageController
- {
- public class Logs
- {
- private static string m_filePath = Application.StartupPath + "\\Logs\\";
- private static void chkFile()
- {
- if (!Directory.Exists(m_filePath))
- {
- Directory.CreateDirectory(m_filePath); //不存在就创建目录
- }
- }
- public static void Write(string str)
- {
- try
- {
- #if DEBUG
- {
- str = DateTime.Now.ToString("HH:mm:ss:fff") + ":" + str;
- chkFile();
- StreamWriter sw = File.AppendText(m_filePath + DateTime.Now.ToString("yyyyMMdd") + ".txt");
- //开始写入
- sw.WriteLine(str);
- //清空缓冲区
- sw.Flush();
- //关闭流
- sw.Close();
- }
- #endif
- }
- catch (Exception)
- {
- }
- }
- //Add by shayg 20220718 start
- public static void WriteFocus(string str)
- {
- try
- {
- #if DEBUG
- {
- str = DateTime.Now.ToString("HH:mm:ss:fff") + ":" + str;
- chkFile();
- StreamWriter sw = File.AppendText(m_filePath + DateTime.Now.ToString("yyyyMMdd") + "_Focus.txt");
- sw.WriteLine(str);
- sw.Flush();
- sw.Close();
- }
- #endif
- }
- catch (Exception)
- {
- }
- }
- //Add by shayg 20220718 end
- }
- }
|