/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Actions/FileSystem/OpenFileLocationAction.cs
77 строк
2 KB
yair100
Fix: Fixed issue where no error was displayed when opening corrupted exe (#18721)
15 июл 2026, 23:06
Не верифицирован
15 июл 2026, 23:06
8674d76
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using System.IO; namespace Files.App.Actions { [GeneratedRichCommand] internal sealed partial class OpenFileLocationAction : ObservableObject, IAction { private readonly IContentPageContext context; public string Label => Strings.OpenFileLocation.GetLocalizedResource(); public string Description => Strings.OpenFileLocationDescription.GetLocalizedResource(); public ActionCategory Category => ActionCategory.Open; public RichGlyph Glyph => new(baseGlyph: "\uE8DA"); public bool IsExecutable => context.ShellPage is not null && context.HasSelection && context.SelectedItem is IShortcutItem; public OpenFileLocationAction() { context = Ioc.Default.GetRequiredService<IContentPageContext>(); context.PropertyChanged += Context_PropertyChanged; } public async Task ExecuteAsync(object? parameter = null) { if (context.ShellPage?.ShellViewModel is null) return; var item = context.SelectedItem as IShortcutItem; if (string.IsNullOrWhiteSpace(item?.TargetPath)) return; // Check if destination path exists var folderPath = Path.GetDirectoryName(item.TargetPath); var destFolder = await context.ShellPage.ShellViewModel.GetFolderWithPathFromPathAsync(folderPath); if (destFolder) { context.ShellPage?.NavigateWithArguments(context.ShellPage.InstanceViewModel.FolderSettings.GetLayoutType(folderPath), new NavigationArguments() { NavPathParam = folderPath, SelectItems = [Path.GetFileName(item.TargetPath.TrimPath())], AssociatedTabInstance = context.ShellPage }); } else if (destFolder == FileSystemStatusCode.NotFound) { await DialogDisplayHelper.ShowDialogAsync(Strings.FileNotFoundDialogTitle.GetLocalizedResource(), Strings.FileNotFoundDialogText.GetLocalizedResource()); } else { await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLocalizedResource(), string.Format(Strings.InvalidItemDialogContent.GetLocalizedResource(), Environment.NewLine, destFolder.ErrorCode.ToString())); } } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName is nameof(IContentPageContext.HasSelection)) OnPropertyChanged(nameof(IsExecutable)); } } }