Esempio n. 1
0
 public static FileSystemWatcherSingle CreateInstance()
 {
     if (_instance == null)
     {
         lock (_objLock)
         {
             if (_instance == null)
             {
                 _instance = new FileSystemWatcherSingle();
             }
         }
     }
     return(_instance);
 }
Esempio n. 2
0
    public static void WriteLog(Log log)
    {
        string dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log");

        if (!Directory.Exists(dir))
        {
            Directory.CreateDirectory(dir);
        }
        string _watherFilePath = Path.Combine(dir, DateTime.Now.ToString("yyyy-MM-dd") + ".log");

        if (!File.Exists(_watherFilePath))
        {
            File.Create(_watherFilePath).Close();
        }
        FileSystemWatcherSingle wather = FileSystemWatcherSingle.CreateInstance();

        wather.MyQueue.Enqueue(log);
        File.AppendAllText(_watherFilePath, string.Format("{0} {1}\r\n{2}", log.Type.ToString(), log.Dt, log.Content));
    }