diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw
index b5e6a587c812..a657214f19b8 100644
--- a/src/Files.App/Strings/en-US/Resources.resw
+++ b/src/Files.App/Strings/en-US/Resources.resw
@@ -3605,4 +3605,7 @@
The option to open Files on Windows Startup is not available due to your system settings or group policy. To re-enable, open the startup page in Task Manager.
+
+ Failed to restore items from Recycle Bin
+
\ No newline at end of file
diff --git a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs
index 3020962b63a6..1adc6d2ff364 100644
--- a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs
+++ b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs
@@ -79,7 +79,7 @@ await ConfirmEmptyBinDialog.TryShowAsync() == ContentDialogResult.Primary)
public static async Task RestoreRecycleBinAsync()
{
- var ConfirmEmptyBinDialog = new ContentDialog()
+ var confirmEmptyBinDialog = new ContentDialog()
{
Title = "ConfirmRestoreBinDialogTitle".GetLocalizedResource(),
Content = "ConfirmRestoreBinDialogContent".GetLocalizedResource(),
@@ -88,11 +88,30 @@ public static async Task RestoreRecycleBinAsync()
DefaultButton = ContentDialogButton.Primary
};
- ContentDialogResult result = await ConfirmEmptyBinDialog.TryShowAsync();
+ if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
+ confirmEmptyBinDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
+
+ ContentDialogResult result = await confirmEmptyBinDialog.TryShowAsync();
if (result == ContentDialogResult.Primary)
{
- Vanara.Windows.Shell.RecycleBin.RestoreAll();
+ try
+ {
+ Vanara.Windows.Shell.RecycleBin.RestoreAll();
+ }
+ catch (Exception)
+ {
+ var errorDialog = new ContentDialog()
+ {
+ Title = "FailedToRestore".GetLocalizedResource(),
+ PrimaryButtonText = "OK".GetLocalizedResource(),
+ };
+
+ if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
+ errorDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot;
+
+ await errorDialog.TryShowAsync();
+ }
}
}