private void ExportButton_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "(*.txt)|*.txt"; saveFileDialog.FileName = Environment.UserName + "-Profile Backup Session"; saveFileDialog.FilterIndex = 2; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { BackupHistoryContainer.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.PlainText); } }
private void BackupHistory_Load(object sender, EventArgs e) { try { using (StreamReader sr = new StreamReader("logs\\" + Environment.UserName + ".txt")) { BackupHistoryContainer.AppendText(sr.ReadToEnd()); } } catch { BackupHistoryContainer.Text = "No log found."; ExportButton.Enabled = false; ClearButton.Enabled = false; } }
private void ClearButton_Click(object sender, EventArgs e) { var NewSessionConfirmation = MessageBox.Show("Clear the log? All previous session data will be lost.", "Clear History", MessageBoxButtons.YesNo); if (NewSessionConfirmation == DialogResult.Yes) { File.Delete("logs\\" + Environment.UserName + ".txt"); BackupHistoryContainer.Clear(); BackupHistoryContainer.Text = "No log found."; ExportButton.Enabled = false; ClearButton.Enabled = false; } else { } }