From cf5addab28fb5ec4a49500ce0c4b18ff3cc529d8 Mon Sep 17 00:00:00 2001 From: Ani <115020168+drawbyperpetual@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:29:08 +0200 Subject: [PATCH] [Settings][New+]Fixed crash when canceling template folder selection (#35060) [New+] Fixed crash when cancel template folder selection --- src/settings-ui/Settings.UI/ViewModels/NewPlusViewModel.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/settings-ui/Settings.UI/ViewModels/NewPlusViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/NewPlusViewModel.cs index 70d2657e37..0cd771d46a 100644 --- a/src/settings-ui/Settings.UI/ViewModels/NewPlusViewModel.cs +++ b/src/settings-ui/Settings.UI/ViewModels/NewPlusViewModel.cs @@ -261,7 +261,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private async void PickNewTemplateFolder() { var newPath = await PickFolderDialog(); - if (newPath.Length > 1) + if (!string.IsNullOrEmpty(newPath)) { TemplateLocation = newPath; } @@ -270,8 +270,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels private async Task PickFolderDialog() { var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.GetSettingsWindow()); - string pathFolder = await Task.FromResult(ShellGetFolder.GetFolderDialogWithFlags(hwnd, ShellGetFolder.FolderDialogFlags._BIF_NEWDIALOGSTYLE)); - return pathFolder; + return await Task.FromResult(GetFolderDialogWithFlags(hwnd, FolderDialogFlags._BIF_NEWDIALOGSTYLE)); } private void SaveSettingsToJson()