Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3605,4 +3605,7 @@
<data name="OpenOnStartupDisabled" xml:space="preserve">
<value>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.</value>
</data>
<data name="FailedToRestore" xml:space="preserve">
<value>Failed to restore items from Recycle Bin</value>
</data>
</root>
25 changes: 22 additions & 3 deletions src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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();
}
}
}

Expand Down