From 4c0271a154eb0aa290343f9c4a8996c60385cfa1 Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Mon, 26 Jun 2023 16:33:04 +0200 Subject: [PATCH] Bootstrap.WinForms: Catch exceptions when checking if directory is empty --- src/Bootstrap.WinForms/MainForm.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bootstrap.WinForms/MainForm.cs b/src/Bootstrap.WinForms/MainForm.cs index adc152a1e..f62846dda 100644 --- a/src/Bootstrap.WinForms/MainForm.cs +++ b/src/Bootstrap.WinForms/MainForm.cs @@ -129,6 +129,9 @@ bool PathIsIn(Environment.SpecialFolder folder) Msg.Inform(this, string.Format(LocalizableStrings.FolderNotNtfs, path), MsgSeverity.Warn); return false; } + + return Directory.GetFileSystemEntries(path).Length == 0 + || Msg.OkCancel(this, string.Format(LocalizableStrings.FolderNotEmpty, path), MsgSeverity.Warn, LocalizableStrings.UseAnyway, LocalizableStrings.ChooseDifferent); } catch (Exception ex) { @@ -136,9 +139,6 @@ bool PathIsIn(Environment.SpecialFolder folder) Msg.Inform(this, ex.Message, MsgSeverity.Error); return false; } - - return Directory.GetFileSystemEntries(path).Length == 0 - || Msg.OkCancel(this, string.Format(LocalizableStrings.FolderNotEmpty, path), MsgSeverity.Warn, LocalizableStrings.UseAnyway, LocalizableStrings.ChooseDifferent); } private void buttonContinue_Click(object sender, EventArgs e)