From: sr55 Date: Sun, 4 Nov 2018 20:14:30 +0000 (+0000) Subject: WinGui: Allow the UI to silently attempt to auto-create folders when adding to the... X-Git-Tag: 1.2.0~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0971a9aaca0b2ff8fa64f64a1f60830b2f47940a;p=handbrake WinGui: Allow the UI to silently attempt to auto-create folders when adding to the queue. Subsequent deletion of said folder will still prompt a queue failure as this is an abnormal situation that would be best reviewed by the user #1654 --- diff --git a/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs b/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs index 7a58721b3..c66a45c0c 100644 --- a/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs +++ b/win/CS/HandBrakeWPF/Utilities/DirectoryUtilities.cs @@ -70,12 +70,20 @@ namespace HandBrakeWPF.Utilities { if (!Directory.Exists(dirPath)) { - MessageBoxResult result = errorService.ShowMessageBox(string.Format(Resources.DirectoryUtils_CreateFolderMsg, dirPath), Resources.DirectoryUtils_CreateFolder, MessageBoxButton.YesNo, MessageBoxImage.Question); - if (result == MessageBoxResult.Yes) + if (createDirectoryPrompt) { - Directory.CreateDirectory(dirPath); + MessageBoxResult result = errorService.ShowMessageBox(string.Format(Resources.DirectoryUtils_CreateFolderMsg, dirPath), Resources.DirectoryUtils_CreateFolder, MessageBoxButton.YesNo, MessageBoxImage.Question); + if (result == MessageBoxResult.Yes) + { + Directory.CreateDirectory(dirPath); + } } + else + { + Directory.CreateDirectory(dirPath); + } } + using (File.Create(Path.Combine(dirPath, Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose)) { } diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 9cfe574ca..45904cb0e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1514,7 +1514,7 @@ namespace HandBrakeWPF.ViewModels } } - if (!DirectoryUtilities.IsWritable(Path.GetDirectoryName(this.CurrentTask.Destination), true, this.errorService)) + if (!DirectoryUtilities.IsWritable(Path.GetDirectoryName(this.CurrentTask.Destination), false, this.errorService)) { this.errorService.ShowMessageBox(Resources.Main_NoPermissionsOrMissingDirectory, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return false;