From 0710b122ed2fb6a3b72f925b2d84d0f495333d94 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Mon, 6 May 2024 21:07:13 -0400 Subject: [PATCH] Select output file if it exists when revealing task output folder in explorer --- TwitchDownloaderWPF/PageQueue.xaml.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/TwitchDownloaderWPF/PageQueue.xaml.cs b/TwitchDownloaderWPF/PageQueue.xaml.cs index 473bffe1..31e52ceb 100644 --- a/TwitchDownloaderWPF/PageQueue.xaml.cs +++ b/TwitchDownloaderWPF/PageQueue.xaml.cs @@ -1,4 +1,5 @@ -using System.Collections.ObjectModel; +using System; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Threading; using System.Windows; @@ -313,7 +314,17 @@ private void MenuItemOpenTaskFolder_Click(object sender, RoutedEventArgs e) return; } - Process.Start(new ProcessStartInfo(outputFolder) { UseShellExecute = true }); + var args = File.Exists(task.OutputFile) + ? $"/select,\"{task.OutputFile}\"" + : $"\"{outputFolder}\""; + + Process.Start(new ProcessStartInfo + { + FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "explorer.exe"), + Arguments = args, + UseShellExecute = true, + WorkingDirectory = outputFolder + }); } } }