From a8013555230c715d3011aca4422c96f76137b672 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 12 Jan 2019 19:56:08 +0000 Subject: [PATCH] WinGui: Make the MRU feature more useful. If the directory is not found, check to see if the Parent directory exists. #1795 --- .../HandBrakeWPF/ViewModels/ViewModelBase.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs index 54da681dc..13396a676 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.ViewModels { using System; + using System.Diagnostics; using System.IO; using Caliburn.Micro; @@ -94,6 +95,23 @@ namespace HandBrakeWPF.ViewModels return filePath; } + // Check if the parent directory still exists. + if (!string.IsNullOrEmpty(filePath) ) + { + try + { + DirectoryInfo parentDirectory = Directory.GetParent(filePath); + if (parentDirectory != null && filePath.Contains(parentDirectory.FullName)) + { + return parentDirectory.FullName; + } + } + catch (Exception exc) + { + Debug.WriteLine(exc); + } + } + return null; } -- 2.40.0