Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
在 FolderBrowserDialog 返回 "" 时不修改 TextBox 的值
Browse files Browse the repository at this point in the history
  • Loading branch information
ricky8955555 committed Jan 23, 2021
1 parent aed0047 commit 99b396b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Extensions/SystemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/Forms/SubjectStorageInfoGettingWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/WindowMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/FolderBrowserDialogUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit 99b396b

Please sign in to comment.