Skip to content

Commit

Permalink
Fix crash when browsing a file on disk that doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
DSPaul committed Nov 23, 2024
1 parent 7e79331 commit 663c2ad
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ViewModels/CodexEditViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ public bool ShowLoading
public RelayCommand BrowsePathCommand => _browsePathCommand ??= new(BrowsePath);
private void BrowsePath()
{
string? initialDir = Path.GetDirectoryName(TempCodex.Sources.Path);
if (!Path.Exists(initialDir))
{
initialDir = string.Empty;
}

OpenFileDialog openFileDialog = new()
{
AddExtension = false,
InitialDirectory = Path.GetDirectoryName(TempCodex.Sources.Path) ?? String.Empty
InitialDirectory = initialDir
};
if (openFileDialog.ShowDialog() == true)
{
Expand Down

0 comments on commit 663c2ad

Please sign in to comment.