From 99b396bbbb800cd564808a9287b0a01f3d2f07f6 Mon Sep 17 00:00:00 2001 From: Ricky8955555 <397050061@qq.com> Date: Sun, 24 Jan 2021 00:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=20FolderBrowserDialog=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20""=20=E6=97=B6=E4=B8=8D=E4=BF=AE=E6=94=B9=20TextBox?= =?UTF-8?q?=20=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extensions/SystemExtensions.cs | 2 ++ src/Forms/SubjectStorageInfoGettingWindow.cs | 2 +- src/Forms/WindowMain.cs | 2 +- src/Utilities/FolderBrowserDialogUtilities.cs | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Extensions/SystemExtensions.cs b/src/Extensions/SystemExtensions.cs index ee9aa2a..8c2eac0 100644 --- a/src/Extensions/SystemExtensions.cs +++ b/src/Extensions/SystemExtensions.cs @@ -21,5 +21,7 @@ public static Exception ShowAndLog(this Exception ex, Logger logger, bool termin return ex; } + + public static string CheckEmpty(this string str) => string.IsNullOrEmpty(str) ? null : str; } } diff --git a/src/Forms/SubjectStorageInfoGettingWindow.cs b/src/Forms/SubjectStorageInfoGettingWindow.cs index 80ba234..b0e8818 100644 --- a/src/Forms/SubjectStorageInfoGettingWindow.cs +++ b/src/Forms/SubjectStorageInfoGettingWindow.cs @@ -33,7 +33,7 @@ public SubjectStorageInfo GetResult(SubjectStorageInfo info = null) private void ButtonGettingPath_Click(object sender, EventArgs e) { - textBoxPath.Text = FolderBrowserDialogUtilities.GetFilePath(); + textBoxPath.Text = FolderBrowserDialogUtilities.GetFilePath() ?? textBoxPath.Text; } private void ButtonOK_Click(object sender, EventArgs e) diff --git a/src/Forms/WindowMain.cs b/src/Forms/WindowMain.cs index 6873736..1f16c9e 100644 --- a/src/Forms/WindowMain.cs +++ b/src/Forms/WindowMain.cs @@ -47,7 +47,7 @@ private void ListViewSubjectStorageInfos_ColumnWidthChanging(object sender, Colu private void ButtonGettingCoursewareSortingSearchingPath_Click(object sender, EventArgs e) { - textBoxCoursewareSortingSearchingPath.Text = FolderBrowserDialogUtilities.GetFilePath(); + textBoxCoursewareSortingSearchingPath.Text = FolderBrowserDialogUtilities.GetFilePath() ?? textBoxCoursewareSortingSearchingPath.Text; UpdateSubjectStorageInfoConfig(); } diff --git a/src/Utilities/FolderBrowserDialogUtilities.cs b/src/Utilities/FolderBrowserDialogUtilities.cs index 0b89c30..ba8d60e 100644 --- a/src/Utilities/FolderBrowserDialogUtilities.cs +++ b/src/Utilities/FolderBrowserDialogUtilities.cs @@ -16,7 +16,7 @@ public static string GetFilePath(string description = "") var dialog = new FolderBrowserDialog() { Description = description }; dialog.ShowDialog(); - return dialog.SelectedPath; + return dialog.SelectedPath.CheckEmpty(); } } }