From 280ef601110eb51bc46fbdf63463c313e62ccc94 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 1 Mar 2024 17:40:17 +0800 Subject: [PATCH] fix: explorer does not recognize path with separator '/' --- src/Native/Windows.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index c7f37c10..9cf7cef7 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -81,17 +81,25 @@ namespace SourceGit.Native { } public void OpenInFileManager(string path, bool select) { - if (select) { - Process.Start("explorer", $"/select,\"{path}\""); + var fullpath = string.Empty; + if (File.Exists(path)) { + fullpath = new FileInfo(path).FullName; } else { - Process.Start("explorer", path); + fullpath = new DirectoryInfo(path).FullName; + } + + if (select) { + Process.Start("explorer", $"/select,\"{fullpath}\""); + } else { + Process.Start("explorer", fullpath); } } public void OpenWithDefaultEditor(string file) { - var info = new ProcessStartInfo("cmd", $"/c start {file}"); - info.CreateNoWindow = true; - Process.Start(info); + var info = new FileInfo(file); + var start = new ProcessStartInfo("cmd", $"/c start {info.FullName}"); + start.CreateNoWindow = true; + Process.Start(start); } } }