I am using the cookie cutter code to get a registry key object in C#:
RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\MyNewKeyName\\");
After I run this code reg = null
. However, if I switch the value passed to OpenSubKey
to be any value in the registry under SOFTWARE that has additional nodes below it reg
will now have a value. I've tried multiple keys with this pattern and it works. If I put any any key name that does not have additional child nodes it does not work. Ultimately I'm trying to read a string value inside of MyNewKeyName
.
Why does my code not work and reg
get populated if my key does not have any additional nodes below it?