public static void Write_Log(string logMSG) { string string_Path = Application.StartupPath + "\\" + System.DateTime.Today.ToString("MM-dd-yyyy") + "." + "txt"; if (!dir_info.Exists) dir_info.Create(); { { log.WriteLine(logMSG); } } }s
public static void show_Logs(RichTextBox txt) { string strPath = Application.StartupPath + "\\" + System.DateTime.Today.ToString("MM-dd-yyyy") + "." + "txt"; if (File.Exists(strPath)) { txt.Text = sReader.ReadToEnd(); sReader.Close(); } else { MessageBox.Show("File not exist.", "error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Form1_Load(object sender, EventArgs e) { show_Logs(richTextBox2); }
Write_Log(richTextBox1.Text); richTextBox1.Clear(); show_Logs(richTextBox2);