Mega Code Archive

 
Categories / C# Tutorial / Windows
 

Delete a key from Registry

using System; using System.Collections.Generic; using System.Text; using Microsoft.Win32; public class MainClass{     static void Main(string[] args){          string strKey;          string strAns;          Console.WriteLine("Enter the key under HKEY_CURRENT_USER to delete");          strKey = Console.ReadLine();          Console.WriteLine("Do you really mean to delete: " + strKey + " and its settings?");          strAns = Console.ReadLine();          strAns = strAns.ToUpper();          if (strAns == "YES" | strAns == "Y")          {                Registry.CurrentUser.DeleteSubKeyTree(strKey);                Console.WriteLine("Key " + strKey + " deleted");          }          else          {                Console.WriteLine("No deletion performed");          }     } }