Fixed a issue where the Installer crashed when a invalid path is in registry.

This commit is contained in:
HorizonCode 2021-06-19 22:12:44 +02:00
parent e43782cfd6
commit 236de72895
2 changed files with 24 additions and 9 deletions

View File

@ -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<bool> 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, "*");

View File

@ -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());
}
}
}
}
}