I'm trying to delete a registry from the Local_Machine\Software in the registry. I made a key titled "DeleteMe" as a test to try it out, but I can't get it to work.
I've tried multiple options, and they all say that the "subkey" "subkeytree" and "value" do not exist, but they do exist! And I hope I'm using the right terminology here. To its HKEY_LOCAL_MACHINE\SOFTWARE\DeleteMe, I want it and all the sub keys/values deleted... (I hope the key is the right terminology. They look just like folders, but when right clicked on, they have the option "copy key name").
So far the best looking thing I've tried was this and I am running as an administrator on Windows 7 (but I want this to work regardless of the OS).
string keyName = @"Software\DeleteMe";
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(keyName, true))
{
if (key == null)
{
MessageBox.Show("Not Found");
}
else
{
key.DeleteSubKeyTree("DeleteMe");
}
}