Delete registry subkey tree

I want to delete a registry subkey tree ONLY if it exists.  How do I tell if it exists?
rmmarshAsked:
Who is Participating?
 
Dov_LandauConnect With a Mentor Commented:
See the code below.
if the key does not exists regKey will become null.

Regards,

Dov

RegistryKey regKey = Registry.LocalMachine.OpenSubKey("Software\\SomeBranch\\SomeSubBranch");

Open in new window

0
 
Dov_LandauCommented:
So if you want to delete the tree i showed - all you have to do is check whether it exists and then call DeleteSubKeyTree.
Regards,
Dov
0
 
rmmarshAuthor Commented:
Thank you...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.