Delete registry subkey tree

Posted on 2009-04-26
Last Modified: 2013-12-17
I want to delete a registry subkey tree ONLY if it exists.  How do I tell if it exists?
Question by:rmmarsh
    LVL 3

    Accepted Solution

    See the code below.
    if the key does not exists regKey will become null.



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

    Open in new window

    LVL 3

    Expert Comment

    So if you want to delete the tree i showed - all you have to do is check whether it exists and then call DeleteSubKeyTree.

    Author Closing Comment

    Thank you...

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now