using Avalonia.Controls; using Avalonia.Interactivity; using System; using System.Diagnostics; using System.IO; namespace ImageCatalog_2.AvaloniaViews; public partial class GeneralTabView : Avalonia.Controls.UserControl { public GeneralTabView() { InitializeComponent(); } private void OpenSourceFolder_Click(object? sender, RoutedEventArgs e) { if (DataContext is DataModel model) { OpenInExplorer(model.SourcePath); } } private void OpenDestinationFolder_Click(object? sender, RoutedEventArgs e) { if (DataContext is DataModel model) { OpenInExplorer(model.DestinationPath); } } private static void OpenInExplorer(string? path) { if (string.IsNullOrWhiteSpace(path)) { return; } var normalizedPath = path.Trim().Trim('"'); try { if (File.Exists(normalizedPath)) { Process.Start("explorer.exe", $"/select,\"{normalizedPath}\""); } else if (Directory.Exists(normalizedPath)) { Process.Start(new ProcessStartInfo { FileName = normalizedPath, UseShellExecute = true }); } } catch { // Ignore failures when opening Explorer. } } }