/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/Open/OpenLogFileAction.cs
63 строки
2 KB
yair100
Code Quality: Updated headers
01 июл 2026, 06:18
01 июл 2026, 06:18
c27305a
Код
Авторство
О чём код?
// Copyright (c) Files Community // SPDX-License-Identifier: MPL-2.0 using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; using Windows.Foundation.Metadata; using Windows.Storage; using Windows.System; namespace Files.App.Actions { [GeneratedRichCommand] internal sealed partial class OpenLogFileAction : IAction { public string Label => Strings.OpenLogFile.GetLocalizedResource(); public string Description => Strings.OpenLogFileDescription.GetLocalizedResource(); public ActionCategory Category => ActionCategory.Open; public HotKey HotKey => new(Keys.OemPeriod, KeyModifiers.Ctrl); public async Task ExecuteAsync(object? parameter = null) { try { var debugFile = await ApplicationData.Current.LocalFolder.TryGetItemAsync("debug.log") as StorageFile; if (debugFile != null && !await Launcher.LaunchFileAsync(debugFile)) { // Fallback to Process.Start if Launcher fails using var process = Process.Start(new ProcessStartInfo(debugFile.Path) { UseShellExecute = true, Verb = "open" }); } } catch (Exception ex) { // Only show the error dialog if no other popups are open if (!VisualTreeHelper.GetOpenPopupsForXamlRoot(MainWindow.Instance.Content.XamlRoot).Any()) { var errorDialog = new ContentDialog() { Title = Strings.FailedToOpenLogFile.GetLocalizedResource(), Content = ex.Message, PrimaryButtonText = Strings.OK.GetLocalizedResource(), }; if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) errorDialog.XamlRoot = MainWindow.Instance.Content.XamlRoot; await errorDialog.TryShowAsync(); } } } } }