mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
fix: try-catch OpenFolderPickerAsync to avoid crash when select a directory is NOT exist
This commit is contained in:
parent
492f22fcfa
commit
80559ce199
6 changed files with 66 additions and 21 deletions
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
|
@ -18,9 +19,16 @@ namespace SourceGit.Views
|
|||
return;
|
||||
|
||||
var options = new FolderPickerOpenOptions() { AllowMultiple = false };
|
||||
var selected = await toplevel.StorageProvider.OpenFolderPickerAsync(options);
|
||||
if (selected.Count == 1)
|
||||
TxtLocation.Text = selected[0].Path.LocalPath;
|
||||
try
|
||||
{
|
||||
var selected = await toplevel.StorageProvider.OpenFolderPickerAsync(options);
|
||||
if (selected.Count == 1)
|
||||
TxtLocation.Text = selected[0].Path.LocalPath;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
App.RaiseException(string.Empty, $"Failed to select location: {exception.Message}");
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue