public MainWindow() { InitializeComponent(); currentFile = new TaskFile(null, ""); }
private void OpenMenuItemClick(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); fileDialog.Filter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*"; if (fileDialog.ShowDialog() == true) { try { using (StreamReader reader = new StreamReader(fileDialog.OpenFile())) { String contents = reader.ReadToEnd(); String filePath = fileDialog.FileName; currentFile = new TaskFile(filePath, contents); UpdateDocumentContents(); } } catch (Exception exception) { Console.WriteLine(exception); } } }