private void deleteButton_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this file?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { File.Delete(@str); Text_File_Contents.Clear(); MessageBox.Show("File deleted"); } }
private void button_Click(object sender, RoutedEventArgs e) { Text_File_Contents.Clear(); OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = ".txt"; if (ofd.ShowDialog() == true) { str = ofd.FileName; Text_File_Contents.Text = File.ReadAllText(str); } MessageBox.Show("Here is the file's contents"); }