Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void writeBarTypeLog(DateTime time, int bar, string msg)
- {
- // local variables
- string path = string.Concat(Cbi.Core.UserDataDir.ToString(), @"log\YourFileName.log");
- FileInfo file = new FileInfo(path);
- // ensure file exists
- if (!file.Exists)
- {
- using (StreamWriter sw = file.CreateText())
- {
- try
- {
- sw.WriteLine(string.Concat("===== ", DateTime.Now.ToString(), " ====="));
- sw.Flush();
- }
- catch (Exception ex) { }
- sw.Close();
- }
- }
- // write debug entry
- using (StreamWriter sw = File.AppendText(path))
- {
- try
- {
- sw.WriteLine("{0} : {1} \r\n{2}", time, bar, msg);
- sw.Flush();
- }
- catch (Exception ex) { }
- sw.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement