Snippet - Logger (edit)
public static class MyLogger
{
private static string M_LogFilePath = "";
static MyLogger()
{
M_LogFilePath = Path.Combine(Application.StartupPath, "Program.log");
if (!File.Exists(M_LogFilePath))
{
using (StreamWriter writer = new StreamWriter(M_LogFilePath, true))
{
writer.WriteLine($"Start Debug at: {DateTime.Now.ToString("yyyy-MM-dd HH:mm tt")}");
}
}
}
public static void AppendLine(string line)
{
using (StreamWriter streamWriter = File.AppendText(M_LogFilePath))
{
streamWriter.WriteLine(line);
}
}
public static void WriteLine(string line)
{
using (StreamWriter streamWriter = new StreamWriter(M_LogFilePath, true))
{
streamWriter.WriteLine(line);
}
}
}