diff --git a/ModAssistant/Classes/Utils.cs b/ModAssistant/Classes/Utils.cs index 1d5ee3e..9d863f8 100644 --- a/ModAssistant/Classes/Utils.cs +++ b/ModAssistant/Classes/Utils.cs @@ -366,6 +366,26 @@ namespace ModAssistant } } + public static void OpenFolder(string location) + { + if (!location.EndsWith(Path.DirectorySeparatorChar.ToString())) location += Path.DirectorySeparatorChar; + if (Directory.Exists(location)) + { + try + { + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo() + { + FileName = location, + UseShellExecute = true, + Verb = "open" + }); + return; + } + catch { } + } + MessageBox.Show($"{string.Format((string)Application.Current.FindResource("Utils:CannotOpenFolder"), location)}."); + } + public static async Task Download(string link, string output) { var resp = await HttpClient.GetAsync(link); diff --git a/ModAssistant/Localisation/en-DEBUG.xaml b/ModAssistant/Localisation/en-DEBUG.xaml index 9cd4ff3..10535c4 100644 --- a/ModAssistant/Localisation/en-DEBUG.xaml +++ b/ModAssistant/Localisation/en-DEBUG.xaml @@ -165,4 +165,5 @@ Utils:NoInstallFolder Utils:RunAsAdmin Utils:InstallDir:DialogTitle + Utils:CannotOpenFolder {0} diff --git a/ModAssistant/Localisation/en-US.xaml b/ModAssistant/Localisation/en-US.xaml index 72c441a..31d7a97 100644 --- a/ModAssistant/Localisation/en-US.xaml +++ b/ModAssistant/Localisation/en-US.xaml @@ -224,4 +224,5 @@ Could not detect your Beat Saber install folder. Please select it manually. Mod Assistant needs to run this task as Admin. Please try again. Select your Beat Saber install folder + Can't open folder: {0} diff --git a/ModAssistant/Pages/Options.xaml.cs b/ModAssistant/Pages/Options.xaml.cs index d1359ad..c24bdac 100644 --- a/ModAssistant/Pages/Options.xaml.cs +++ b/ModAssistant/Pages/Options.xaml.cs @@ -58,7 +58,7 @@ namespace ModAssistant.Pages private void OpenDirButton_Click(object sender, RoutedEventArgs e) { - System.Diagnostics.Process.Start(InstallDirectory); + Utils.OpenFolder(InstallDirectory); } private void Test_Click(object sender, RoutedEventArgs e) @@ -162,7 +162,7 @@ namespace ModAssistant.Pages string title = (string)Application.Current.FindResource("Options:LogUploadFailed:Title"); string body = (string)Application.Current.FindResource("Options:LogUploadFailed:Body"); MessageBox.Show($"{body}\n ================= \n" + exception, title); - System.Diagnostics.Process.Start(Path.Combine(InstallDirectory, "Logs")); + Utils.OpenFolder(Path.Combine(InstallDirectory, "Logs")); } } @@ -196,7 +196,7 @@ namespace ModAssistant.Pages string location = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "Hyperbolic Magnetism"); - System.Diagnostics.Process.Start(location); + Utils.OpenFolder(location); } private async void YeetBSIPAButton_Click(object sender, RoutedEventArgs e) @@ -272,7 +272,7 @@ namespace ModAssistant.Pages { if (Directory.Exists(Themes.ThemeDirectory)) { - System.Diagnostics.Process.Start(Themes.ThemeDirectory); + Utils.OpenFolder(Themes.ThemeDirectory); } else {