public static void WriteLog(string logMessage) { string stringLogPath = @"C:\TransactionLogs\ActionLog-" + System.DateTime.Today.ToString("MM-dd-yyyy") + "." + "txt"; if (!log_DirInfo.Exists) log_DirInfo.Create(); { { log.WriteLine(logMessage); } } }
private void button1_Click(object sender, EventArgs e) { WriteLog("The button is clicked!"); }