diff --git a/EZPPClient Installer/MainWindow.xaml.cs b/EZPPClient Installer/MainWindow.xaml.cs index c918af3..7ad0121 100644 --- a/EZPPClient Installer/MainWindow.xaml.cs +++ b/EZPPClient Installer/MainWindow.xaml.cs @@ -107,12 +107,15 @@ namespace EZPPClient_Installer folderTextbox.Text = osuPath; } else + { + folderTextbox.Text = ""; await new ContentDialog() { Title = "Hmmm..", Content = "We failed to locate your osu! Installation path, please define it manually qwq", PrimaryButtonText = "Okay qwq" }.ShowAsync(); + } } @@ -633,7 +636,7 @@ namespace EZPPClient_Installer private async Task isValidOsuFolder(string folder) { - if (string.IsNullOrEmpty(folder) || string.IsNullOrWhiteSpace(folder)) + if (string.IsNullOrEmpty(folder) || string.IsNullOrWhiteSpace(folder) || !Directory.Exists(folder)) return false; string[] files = Directory.GetFiles(folder, "*"); string[] subDirs = Directory.GetDirectories(folder, "*"); diff --git a/EZPPClient Installer/Utils/OsuUtil.cs b/EZPPClient Installer/Utils/OsuUtil.cs index c33fd72..d4e9f44 100644 --- a/EZPPClient Installer/Utils/OsuUtil.cs +++ b/EZPPClient Installer/Utils/OsuUtil.cs @@ -13,13 +13,19 @@ namespace EZPPClient_Installer using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key)) { - foreach (string subkey_name in key.GetSubKeyNames()) + if (key != null && key.GetSubKeyNames() != null) { - using (RegistryKey subkey = key.OpenSubKey(subkey_name)) + foreach (string subkey_name in key.GetSubKeyNames()) { - if ((string)subkey.GetValue("DisplayName") == "osu!") + using (RegistryKey subkey = key.OpenSubKey(subkey_name)) { - path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString()); + if (subkey != null) + { + if ((string)subkey.GetValue("DisplayName") == "osu!") + { + path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString()); + } + } } } } @@ -29,13 +35,19 @@ namespace EZPPClient_Installer { using (Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(second_registry_key)) { - foreach (string subkey_name in key.GetSubKeyNames()) + if (key != null && key.GetSubKeyNames() != null) { - using (RegistryKey subkey = key.OpenSubKey(subkey_name)) + foreach (string subkey_name in key.GetSubKeyNames()) { - if ((string)subkey.GetValue("DisplayName") == "osu!") + using (RegistryKey subkey = key.OpenSubKey(subkey_name)) { - path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString()); + if (subkey != null) + { + if ((string)subkey.GetValue("DisplayName") == "osu!") + { + path = Path.GetDirectoryName(subkey.GetValue("DisplayIcon").ToString()); + } + } } } }