From 6d855e9ef05304fcf724ff95c9acbab21533d5f3 Mon Sep 17 00:00:00 2001 From: Jaex Date: Thu, 6 Dec 2018 21:51:41 +0300 Subject: [PATCH] Process usage refactor --- ShareX.HelpersLib/CLI/ExternalCLIManager.cs | 28 +++++----- ShareX.HelpersLib/ExternalProgram.cs | 51 +++++++++---------- ShareX.HelpersLib/Helpers/Helpers.cs | 31 ++++++++++- ShareX.HelpersLib/Helpers/URLHelpers.cs | 23 ++++++--- ShareX.HelpersLib/SevenZipManager.cs | 34 +++++++------ .../UpdateChecker/DownloaderForm.cs | 39 +++++++------- ShareX.HistoryLib/HistoryItemManager.cs | 4 +- ShareX.MediaLib/VideoThumbnailer.cs | 19 ++++--- .../Forms/FFmpegOptionsForm.cs | 28 +++++++--- ShareX.Setup/Program.cs | 37 +++++++++----- ShareX.Setup/SetupHelpers.cs | 19 ++++--- ShareX.Steam/Launcher.cs | 46 +++++++++++------ ShareX/Forms/AfterUploadForm.cs | 10 +--- ShareX/Forms/NotificationForm.cs | 2 +- ShareX/TaskHelpers.cs | 17 +++++-- ShareX/UploadInfoManager.cs | 6 +-- 16 files changed, 245 insertions(+), 149 deletions(-) diff --git a/ShareX.HelpersLib/CLI/ExternalCLIManager.cs b/ShareX.HelpersLib/CLI/ExternalCLIManager.cs index 68c8baccb..1e79ec8a4 100644 --- a/ShareX.HelpersLib/CLI/ExternalCLIManager.cs +++ b/ShareX.HelpersLib/CLI/ExternalCLIManager.cs @@ -40,28 +40,32 @@ public abstract class ExternalCLIManager : IDisposable public virtual int Open(string path, string args = null) { - DebugHelper.WriteLine("CLI: \"{0}\" {1}", path, args); - if (File.Exists(path)) { using (process = new Process()) { - ProcessStartInfo psi = new ProcessStartInfo(path); - psi.UseShellExecute = false; - psi.CreateNoWindow = true; - psi.RedirectStandardInput = true; - psi.RedirectStandardOutput = true; - psi.RedirectStandardError = true; - psi.Arguments = args; - psi.WorkingDirectory = Path.GetDirectoryName(path); - psi.StandardOutputEncoding = Encoding.UTF8; - psi.StandardErrorEncoding = Encoding.UTF8; + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = path, + WorkingDirectory = Path.GetDirectoryName(path), + Arguments = args, + UseShellExecute = false, + CreateNoWindow = true, + RedirectStandardInput = true, + RedirectStandardOutput = true, + RedirectStandardError = true, + StandardOutputEncoding = Encoding.UTF8, + StandardErrorEncoding = Encoding.UTF8 + }; process.EnableRaisingEvents = true; if (psi.RedirectStandardOutput) process.OutputDataReceived += cli_OutputDataReceived; if (psi.RedirectStandardError) process.ErrorDataReceived += cli_ErrorDataReceived; process.StartInfo = psi; + + DebugHelper.WriteLine($"CLI: \"{psi.FileName}\" {psi.Arguments}"); process.Start(); + if (psi.RedirectStandardOutput) process.BeginOutputReadLine(); if (psi.RedirectStandardError) process.BeginErrorReadLine(); diff --git a/ShareX.HelpersLib/ExternalProgram.cs b/ShareX.HelpersLib/ExternalProgram.cs index 8552da3b9..7d9942deb 100644 --- a/ShareX.HelpersLib/ExternalProgram.cs +++ b/ShareX.HelpersLib/ExternalProgram.cs @@ -71,41 +71,41 @@ public string Run(string inputPath) { string outputPath = inputPath; - using (Process process = new Process()) + string arguments; + + if (string.IsNullOrEmpty(Args)) { - ProcessStartInfo psi = new ProcessStartInfo(Path); - psi.UseShellExecute = false; + arguments = '"' + inputPath + '"'; + } + else + { + if (!string.IsNullOrWhiteSpace(OutputExtension)) + { + outputPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(inputPath), System.IO.Path.GetFileNameWithoutExtension(inputPath)); - if (string.IsNullOrEmpty(Args)) - { - psi.Arguments = '"' + inputPath + '"'; - } - else - { - if (!string.IsNullOrWhiteSpace(OutputExtension)) + if (!OutputExtension.StartsWith(".")) { - outputPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(inputPath), System.IO.Path.GetFileNameWithoutExtension(inputPath)); - - if (!OutputExtension.StartsWith(".")) - { - outputPath += "."; - } - - outputPath += OutputExtension; + outputPath += "."; } - psi.Arguments = CodeMenuEntryActions.Parse(Args, inputPath, outputPath); + outputPath += OutputExtension; } - if (HiddenWindow) + arguments = CodeMenuEntryActions.Parse(Args, inputPath, outputPath); + } + + using (Process process = new Process()) + { + ProcessStartInfo psi = new ProcessStartInfo() { - psi.CreateNoWindow = true; - } + FileName = Path, + Arguments = arguments, + UseShellExecute = false, + CreateNoWindow = HiddenWindow + }; process.StartInfo = psi; - - DebugHelper.WriteLine($"Running \"{psi.FileName}\" with arguments: {psi.Arguments}"); - + DebugHelper.WriteLine($"CLI: \"{psi.FileName}\" {psi.Arguments}"); process.Start(); process.WaitForExit(); } @@ -115,7 +115,6 @@ public string Run(string inputPath) if (DeleteInputFile && !inputPath.Equals(outputPath, StringComparison.OrdinalIgnoreCase) && File.Exists(inputPath)) { DebugHelper.WriteLine("Deleting input file: " + inputPath); - File.Delete(inputPath); } diff --git a/ShareX.HelpersLib/Helpers/Helpers.cs b/ShareX.HelpersLib/Helpers/Helpers.cs index f8d1efd68..f5e97f447 100644 --- a/ShareX.HelpersLib/Helpers/Helpers.cs +++ b/ShareX.HelpersLib/Helpers/Helpers.cs @@ -424,7 +424,19 @@ public static bool OpenFile(string filePath) { try { - Process.Start(filePath); + using (Process process = new Process()) + { + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = filePath + }; + + process.StartInfo = psi; + process.Start(); + } + + DebugHelper.WriteLine("File opened: " + filePath); + return true; } catch (Exception e) @@ -451,7 +463,19 @@ public static bool OpenFolder(string folderPath) try { - Process.Start(folderPath); + using (Process process = new Process()) + { + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = folderPath + }; + + process.StartInfo = psi; + process.Start(); + } + + DebugHelper.WriteLine("Folder opened: " + folderPath); + return true; } catch (Exception e) @@ -474,6 +498,9 @@ public static bool OpenFolderWithFile(string filePath) try { NativeMethods.OpenFolderAndSelectFile(filePath); + + DebugHelper.WriteLine("Folder opened with file: " + filePath); + return true; } catch (Exception e) diff --git a/ShareX.HelpersLib/Helpers/URLHelpers.cs b/ShareX.HelpersLib/Helpers/URLHelpers.cs index ad181a9ee..6e6a6e4f0 100644 --- a/ShareX.HelpersLib/Helpers/URLHelpers.cs +++ b/ShareX.HelpersLib/Helpers/URLHelpers.cs @@ -52,20 +52,29 @@ public static void OpenURL(string url) { try { - if (!string.IsNullOrEmpty(HelpersOptions.BrowserPath)) + using (Process process = new Process()) { - Process.Start(HelpersOptions.BrowserPath, url); - } - else - { - Process.Start(url); + ProcessStartInfo psi = new ProcessStartInfo(); + + if (!string.IsNullOrEmpty(HelpersOptions.BrowserPath)) + { + psi.FileName = HelpersOptions.BrowserPath; + psi.Arguments = url; + } + else + { + psi.FileName = url; + } + + process.StartInfo = psi; + process.Start(); } DebugHelper.WriteLine("URL opened: " + url); } catch (Exception e) { - DebugHelper.WriteException(e, string.Format("OpenURL({0}) failed", url)); + DebugHelper.WriteException(e, $"OpenURL({url}) failed"); } }); } diff --git a/ShareX.HelpersLib/SevenZipManager.cs b/ShareX.HelpersLib/SevenZipManager.cs index 83fc75f28..9bb29a50b 100644 --- a/ShareX.HelpersLib/SevenZipManager.cs +++ b/ShareX.HelpersLib/SevenZipManager.cs @@ -71,25 +71,27 @@ public bool Compress(string archivePath, List files, string workingDirec private int Run(string arguments, string workingDirectory = "") { - ProcessStartInfo startInfo = new ProcessStartInfo() + using (Process process = new Process()) { - FileName = SevenZipPath, - Arguments = arguments, - UseShellExecute = false, - CreateNoWindow = true - }; + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = SevenZipPath, + Arguments = arguments, + UseShellExecute = false, + CreateNoWindow = true + }; - if (!string.IsNullOrEmpty(workingDirectory)) - { - startInfo.WorkingDirectory = workingDirectory; + if (!string.IsNullOrEmpty(workingDirectory)) + { + psi.WorkingDirectory = workingDirectory; + } + + process.StartInfo = psi; + process.Start(); + process.WaitForExit(); + + return process.ExitCode; } - - Process process = new Process(); - process.StartInfo = startInfo; - process.Start(); - process.WaitForExit(); - - return process.ExitCode; } } } \ No newline at end of file diff --git a/ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs b/ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs index eba92e1b2..d6ca597f1 100644 --- a/ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs +++ b/ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs @@ -150,27 +150,32 @@ private void RunInstaller() { try { - ProcessStartInfo psi = new ProcessStartInfo(DownloadLocation) + using (Process process = new Process()) { - Arguments = "/UPDATE" - }; + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = DownloadLocation, + Arguments = "/UPDATE", + UseShellExecute = false + }; - if (InstallType == InstallType.Silent) - { - psi.Arguments += " /SILENT"; - } - else if (InstallType == InstallType.VerySilent) - { - psi.Arguments += " /VERYSILENT"; - } + if (InstallType == InstallType.Silent) + { + psi.Arguments += " /SILENT"; + } + else if (InstallType == InstallType.VerySilent) + { + psi.Arguments += " /VERYSILENT"; + } - if (Helpers.IsDefaultInstallDir()) - { - psi.Verb = "runas"; - } + if (Helpers.IsDefaultInstallDir()) + { + psi.Verb = "runas"; + } - psi.UseShellExecute = true; - Process.Start(psi); + process.StartInfo = psi; + process.Start(); + } } catch { diff --git a/ShareX.HistoryLib/HistoryItemManager.cs b/ShareX.HistoryLib/HistoryItemManager.cs index 0ba321b04..c0ff115be 100644 --- a/ShareX.HistoryLib/HistoryItemManager.cs +++ b/ShareX.HistoryLib/HistoryItemManager.cs @@ -137,7 +137,7 @@ public void OpenDeletionURL() public void OpenFile() { - if (HistoryItem != null && IsFileExist) URLHelpers.OpenURL(HistoryItem.Filepath); + if (HistoryItem != null && IsFileExist) Helpers.OpenFile(HistoryItem.Filepath); } public void OpenFolder() @@ -159,7 +159,7 @@ public void TryOpen() } else if (IsFileExist) { - URLHelpers.OpenURL(HistoryItem.Filepath); + Helpers.OpenFile(HistoryItem.Filepath); } } } diff --git a/ShareX.MediaLib/VideoThumbnailer.cs b/ShareX.MediaLib/VideoThumbnailer.cs index 6ebbe6be8..29b2658ae 100644 --- a/ShareX.MediaLib/VideoThumbnailer.cs +++ b/ShareX.MediaLib/VideoThumbnailer.cs @@ -76,14 +76,19 @@ public List TakeThumbnails() string filename = string.Format("{0}-{1}.{2}", mediaFileName, timeSliceElapsed, Options.ImageFormat.GetDescription()); string tempThumbnailPath = Path.Combine(GetOutputDirectory(), filename); - using (Process p = new Process()) + using (Process process = new Process()) { - ProcessStartInfo psi = new ProcessStartInfo(FFmpegPath); - psi.WindowStyle = ProcessWindowStyle.Hidden; - psi.Arguments = string.Format("-ss {0} -i \"{1}\" -f image2 -vframes 1 -y \"{2}\"", timeSliceElapsed, MediaPath, tempThumbnailPath); - p.StartInfo = psi; - p.Start(); - p.WaitForExit(1000 * 30); + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = FFmpegPath, + Arguments = $"-ss {timeSliceElapsed} -i \"{MediaPath}\" -f image2 -vframes 1 -y \"{tempThumbnailPath}\"", + UseShellExecute = false, + CreateNoWindow = true + }; + + process.StartInfo = psi; + process.Start(); + process.WaitForExit(1000 * 30); } if (File.Exists(tempThumbnailPath)) diff --git a/ShareX.ScreenCaptureLib/Forms/FFmpegOptionsForm.cs b/ShareX.ScreenCaptureLib/Forms/FFmpegOptionsForm.cs index cbaa2a637..3eb5aea66 100644 --- a/ShareX.ScreenCaptureLib/Forms/FFmpegOptionsForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/FFmpegOptionsForm.cs @@ -280,9 +280,9 @@ private void cboAudioSource_SelectedIndexChanged(object sender, EventArgs e) private async void btnInstallHelperDevices_Click(object sender, EventArgs e) { - string filepath = Helpers.GetAbsolutePath(FFmpegHelper.DeviceSetupPath); + string filePath = Helpers.GetAbsolutePath(FFmpegHelper.DeviceSetupPath); - if (!string.IsNullOrEmpty(filepath) && File.Exists(filepath)) + if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath)) { bool result = false; @@ -290,9 +290,17 @@ private async void btnInstallHelperDevices_Click(object sender, EventArgs e) { try { - Process process = Process.Start(filepath); + using (Process process = new Process()) + { + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = filePath + }; - result = process.WaitForExit(1000 * 60 * 5) && process.ExitCode == 0; + process.StartInfo = psi; + process.Start(); + result = process.WaitForExit(1000 * 60 * 5) && process.ExitCode == 0; + } } catch { } }); @@ -304,7 +312,7 @@ private async void btnInstallHelperDevices_Click(object sender, EventArgs e) } else { - MessageBox.Show("File not exists: \"" + filepath + "\"", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("File not exists: \"" + filePath + "\"", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -491,9 +499,13 @@ private void btnTest_Click(object sender, EventArgs e) { using (Process process = new Process()) { - ProcessStartInfo psi = new ProcessStartInfo("cmd.exe"); - psi.Arguments = $"/k {Path.GetFileName(Options.FFmpeg.FFmpegPath)} {Options.GetFFmpegCommands()}"; - psi.WorkingDirectory = Path.GetDirectoryName(Options.FFmpeg.FFmpegPath); + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = "cmd.exe", + WorkingDirectory = Path.GetDirectoryName(Options.FFmpeg.FFmpegPath), + Arguments = $"/k {Path.GetFileName(Options.FFmpeg.FFmpegPath)} {Options.GetFFmpegCommands()}", + UseShellExecute = true + }; process.StartInfo = psi; process.Start(); diff --git a/ShareX.Setup/Program.cs b/ShareX.Setup/Program.cs index 24fd53c99..575173a4b 100644 --- a/ShareX.Setup/Program.cs +++ b/ShareX.Setup/Program.cs @@ -173,20 +173,22 @@ private static void Main(string[] args) if (Job.HasFlag(SetupJobs.CompileAppx)) { - Process p = new Process + using (Process process = new Process()) { - StartInfo = new ProcessStartInfo + ProcessStartInfo psi = new ProcessStartInfo() { FileName = MakeAppxPath, Arguments = $"pack /d \"{WindowsStoreOutputDir}\" /p \"{WindowsStoreAppxPath}\" /l /o", UseShellExecute = false, RedirectStandardOutput = true - } - }; - p.OutputDataReceived += (s, e) => Console.WriteLine(e.Data); - p.Start(); - p.BeginOutputReadLine(); - p.WaitForExit(); + }; + + process.OutputDataReceived += (s, e) => Console.WriteLine(e.Data); + process.StartInfo = psi; + process.Start(); + process.BeginOutputReadLine(); + process.WaitForExit(); + } Directory.Delete(WindowsStoreOutputDir, true); } @@ -226,11 +228,20 @@ private static void CompileISSFile(string filename) { Console.WriteLine("Compiling setup file: " + filename); - ProcessStartInfo startInfo = new ProcessStartInfo(InnoSetupCompilerPath, $"\"{filename}\""); - startInfo.UseShellExecute = false; - startInfo.WorkingDirectory = Path.GetFullPath(InnoSetupDir); - Process process = Process.Start(startInfo); - process.WaitForExit(); + using (Process process = new Process()) + { + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = InnoSetupCompilerPath, + WorkingDirectory = Path.GetFullPath(InnoSetupDir), + Arguments = $"\"{filename}\"", + UseShellExecute = false + }; + + process.StartInfo = psi; + process.Start(); + process.WaitForExit(); + } Console.WriteLine("Setup file is created."); } diff --git a/ShareX.Setup/SetupHelpers.cs b/ShareX.Setup/SetupHelpers.cs index dcd99111c..7b19e2e0d 100644 --- a/ShareX.Setup/SetupHelpers.cs +++ b/ShareX.Setup/SetupHelpers.cs @@ -94,15 +94,20 @@ private static void ProcessStart(string filePath, string arguments) { Console.WriteLine($"Process starting: {filePath} {arguments}"); - ProcessStartInfo startInfo = new ProcessStartInfo() + using (Process process = new Process()) { - FileName = filePath, - Arguments = arguments, - UseShellExecute = false, - CreateNoWindow = true - }; + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = filePath, + Arguments = arguments, + UseShellExecute = false, + CreateNoWindow = true + }; - Process.Start(startInfo).WaitForExit(); + process.StartInfo = psi; + process.Start(); + process.WaitForExit(); + } } public static bool CheckArguments(string[] args, string check) diff --git a/ShareX.Steam/Launcher.cs b/ShareX.Steam/Launcher.cs index 3e3a3ebfd..9d9e615cc 100644 --- a/ShareX.Steam/Launcher.cs +++ b/ShareX.Steam/Launcher.cs @@ -186,14 +186,18 @@ private static void RunShareX(string arguments = "") { if (ShowInApp) { - ProcessStartInfo startInfo = new ProcessStartInfo() + using (Process process = new Process()) { - Arguments = arguments, - FileName = ContentExecutablePath, - UseShellExecute = true - }; + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = ContentExecutablePath, + Arguments = arguments, + UseShellExecute = true + }; - Process.Start(startInfo); + process.StartInfo = psi; + process.Start(); + } } else { @@ -220,15 +224,19 @@ private static void RunShareX(string arguments = "") path = "cmd.exe"; } - ProcessStartInfo startInfo = new ProcessStartInfo() + using (Process process = new Process()) { - Arguments = $"/C start \"\" \"{ContentExecutablePath}\" {arguments}", - CreateNoWindow = true, - FileName = path, - UseShellExecute = false - }; + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = path, + Arguments = $"/C start \"\" \"{ContentExecutablePath}\" {arguments}", + UseShellExecute = false, + CreateNoWindow = true + }; - Process.Start(startInfo); + process.StartInfo = psi; + process.Start(); + } } } catch (Exception e) @@ -254,10 +262,16 @@ private static void UninstallShareX() { if (File.Exists(ContentExecutablePath)) { - Process process = Process.Start(ContentExecutablePath, "-uninstall"); - - if (process != null) + using (Process process = new Process()) { + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = ContentExecutablePath, + Arguments = "-uninstall" + }; + + process.StartInfo = psi; + process.Start(); process.WaitForExit(); } } diff --git a/ShareX/Forms/AfterUploadForm.cs b/ShareX/Forms/AfterUploadForm.cs index 66722356c..e787cda1d 100644 --- a/ShareX/Forms/AfterUploadForm.cs +++ b/ShareX/Forms/AfterUploadForm.cs @@ -176,18 +176,12 @@ private void btnOpenLink_Click(object sender, EventArgs e) private void btnOpenFile_Click(object sender, EventArgs e) { - if (!string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath)) - { - URLHelpers.OpenURL(Info.FilePath); - } + Helpers.OpenFile(Info.FilePath); } private void btnFolderOpen_Click(object sender, EventArgs e) { - if (!string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath)) - { - Helpers.OpenFolderWithFile(Info.FilePath); - } + Helpers.OpenFolderWithFile(Info.FilePath); } private void btnClose_Click(object sender, EventArgs e) diff --git a/ShareX/Forms/NotificationForm.cs b/ShareX/Forms/NotificationForm.cs index d8fcfd54a..655a4f157 100644 --- a/ShareX/Forms/NotificationForm.cs +++ b/ShareX/Forms/NotificationForm.cs @@ -238,7 +238,7 @@ private void ExecuteAction(ToastClickAction action) break; case ToastClickAction.OpenFile: if (!string.IsNullOrEmpty(ToastConfig.FilePath)) - URLHelpers.OpenURL(ToastConfig.FilePath); + Helpers.OpenFile(ToastConfig.FilePath); break; case ToastClickAction.OpenFolder: if (!string.IsNullOrEmpty(ToastConfig.FilePath)) diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs index 391a5455b..555bf70c0 100644 --- a/ShareX/TaskHelpers.cs +++ b/ShareX/TaskHelpers.cs @@ -1085,10 +1085,19 @@ public static void RunShareXAsAdmin(string arguments) { try { - ProcessStartInfo psi = new ProcessStartInfo(Application.ExecutablePath); - psi.Arguments = arguments; - psi.Verb = "runas"; - Process.Start(psi); + using (Process process = new Process()) + { + ProcessStartInfo psi = new ProcessStartInfo() + { + FileName = Application.ExecutablePath, + Arguments = arguments, + UseShellExecute = false, + Verb = "runas" + }; + + process.StartInfo = psi; + process.Start(); + } } catch { diff --git a/ShareX/UploadInfoManager.cs b/ShareX/UploadInfoManager.cs index fd2177ce6..95482e6ea 100644 --- a/ShareX/UploadInfoManager.cs +++ b/ShareX/UploadInfoManager.cs @@ -119,12 +119,12 @@ public void OpenDeletionURL() public void OpenFile() { - if (IsItemSelected && SelectedItem.IsFileExist) URLHelpers.OpenURL(SelectedItem.Info.FilePath); + if (IsItemSelected && SelectedItem.IsFileExist) Helpers.OpenFile(SelectedItem.Info.FilePath); } public void OpenThumbnailFile() { - if (IsItemSelected && SelectedItem.IsThumbnailFileExist) URLHelpers.OpenURL(SelectedItem.Info.ThumbnailFilePath); + if (IsItemSelected && SelectedItem.IsThumbnailFileExist) Helpers.OpenFile(SelectedItem.Info.ThumbnailFilePath); } public void OpenFolder() @@ -146,7 +146,7 @@ public void TryOpen() } else if (SelectedItem.IsFilePathValid) { - URLHelpers.OpenURL(SelectedItem.Info.FilePath); + Helpers.OpenFile(SelectedItem.Info.FilePath); } } }