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(); } } }