retesere20

nt7 -bartype debug

Oct 14th, 2019
153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. void writeBarTypeLog(DateTime time, int bar, string msg)
  3. {
  4. // local variables
  5. string path = string.Concat(Cbi.Core.UserDataDir.ToString(), @"log\YourFileName.log");
  6. FileInfo file = new FileInfo(path);
  7.  
  8. // ensure file exists
  9. if (!file.Exists)
  10. {
  11. using (StreamWriter sw = file.CreateText())
  12. {
  13. try
  14. {
  15. sw.WriteLine(string.Concat("===== ", DateTime.Now.ToString(), " ====="));
  16. sw.Flush();
  17. }
  18. catch (Exception ex) { }
  19.  
  20. sw.Close();
  21. }
  22. }
  23.  
  24. // write debug entry
  25. using (StreamWriter sw = File.AppendText(path))
  26. {
  27. try
  28. {
  29. sw.WriteLine("{0} : {1} \r\n{2}", time, bar, msg);
  30. sw.Flush();
  31. }
  32. catch (Exception ex) { }
  33.  
  34. sw.Close();
  35. }
  36. }
RAW Paste Data