System.ArgumentException = while deleting registry key

A

Asawari

Hi

I'm trying to delete 1 registry key. It is giving me exception as
System.ArgumentException: Cannot delete a subkey tree because the
subkey does not exist.

For deleting subkey, how to provide the key name?

For e.g.

1) "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" + "\\" +
subKeyName

Here "subKeyName" implies the software that is to be deleted.

OR

2) only subKeyName

OR

3)
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
+ "\\" + subKeyName

Any help / clue will be very much helpful.
Thanks in advance.

Regards
Asawari
 
K

Kalpesh

I guess - you want to delete 1 key & you are using "DeleteSubKeyTree"
Try using "DeleteSubKey" instead

HTH
Kalpesh
 
A

Asawari

No.
i'm using DeleteSubKey method only.

Inspite of using this method, it's giving this exception.

Regards
Asawari
 
K

Kalpesh

If the key does not have further keys under it (in left pane)
Registry.LocalMachine.DeleteSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blah");

Use DeleteSubKeyTree, if it has further keys under it (as in
sub-folders)

HTH
Kalpesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top