LogTool.cs 947 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Text;
  6. namespace MAutoUpdate
  7. {
  8. public static class LogTool
  9. {
  10. static string temp = @"C://eap";//AppDomain.CurrentDomain.BaseDirectory;
  11. public static void AddLog(String value)
  12. {
  13. try
  14. {
  15. Debug.WriteLine(value);
  16. if (Directory.Exists(Path.Combine(temp, @"log\")) == false)
  17. {
  18. DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(temp, @"log\"));
  19. directoryInfo.Create();
  20. }
  21. using (StreamWriter sw = File.AppendText(Path.Combine(temp, @"log\update.log")))
  22. {
  23. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "--->" + value);
  24. }
  25. }
  26. catch
  27. {
  28. }
  29. }
  30. }
  31. }