/// <summary> /// Gets the times from a file and sets them in the view model /// </summary> private void SelectFile() { // I know this shouldn't be done this way but I don't know how to do it otherwise // TODO: Do this in a MVVM conform way OpenFileDialog openFileDialog = new OpenFileDialog(); bool?result = openFileDialog.ShowDialog(); if (result == true) { openFileDialog.Title = "Select a file"; openFileDialog.Filter = "All files (*.*) | *.*"; FullPath = openFileDialog.FileName; } // Get the times var times = FileProperties.GetTimes(FullPath); try { // Try to set the times CreationTime = times[0]; ModificationTime = times[1]; LastAccessTime = times[2]; // Enable the text boxes IsEnabled = true; // Hide the error message FileErrorMessage = Visibility.Hidden; // Clear the output ApplyOutput = string.Empty; } catch { // Otherwise set them to empty strings CreationTime = string.Empty; ModificationTime = string.Empty; LastAccessTime = string.Empty; // Disable text boxes IsEnabled = false; // Show the error message FileErrorMessage = Visibility.Visible; } }