I am making a concept of registry viewer that gets all the names
of the subkey in the registry and lists all the names in the console. and on the
string[] subKeyNames = jdfddnjdz.GetSubKeyNames();
i get an error which is Object reference not set to an instance of an object.
here's the code.
RegistryKey jdfddnjdz = Registry.CurrentUser.OpenSubKey(@"\SOFTWARE\Example\");
string[] subKeyNames = jdfddnjdz.GetSubKeyNames();
foreach (String val5 in subKeyNames)
{
Console.WriteLine(val5);
Console.ReadKey();
}
Edit:
This code works fine but if I add .OpenSubKey
like in the code above this it gives an error.
RegistryKey subKey = Registry.CurrentUser;
string[] subkeyNemez = subKey.GetSubKeyNames();
foreach (String valuef in subkeyNemez)
{
Console.WriteLine(valuef);
Console.ReadKey();
}