I created the following registry key (copied via regedit):
HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ test
I would like to delete this registry key, and therefore ... I used the following code and ran a small error.
Reg RegKKey regKey;
string regPath_Key = @"Software\Microsoft\Windows\CurrentVersion\test";
regKey = Registry.CurrentUser.OpenSubKey(regPath_Key, true);
if(regKey != null)
{
Registry.CurrentUser.DeleteSubKey(regPath_Key, true);
}
The problem I ran into is that the string if(regKey != null)always returns null! I came back and checked that the key does exist several times, but still the same result. Am I going to suggest that my code has problems somewhere?
user725913
source
share