Delete a setting in Registry : Registry Save « Windows « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;


public class MainClass{

    static void Main(string[] args){
        string strKey;
        string strSetting;
        string strAns;
        Console.WriteLine("Enter the key");
        strKey = Console.ReadLine();
        RegistryKey TestProject = Registry.CurrentUser.OpenSubKey(strKey, true);
        Console.WriteLine("Enter the setting");
        strSetting = Console.ReadLine();
        Console.WriteLine("Do you really mean to delete: " + strKey + "\\" + strSetting + "?");
        strAns = Console.ReadLine();
        strAns = strAns.ToUpper();
        if (strAns == "Y" | strAns == "YES")
        {
             TestProject.DeleteValue(strSetting);
             Console.WriteLine("Key setting " + strKey + "\\" + strSetting + " deleted");
        }
        else
        {
             Console.WriteLine("No deletion performed; key closed");
             TestProject.Close();
        }
    }

}








29.2.Registry Save
29.2.1.Save int value to Registry
29.2.2.Set DateTime value to the Registry
29.2.3.Set String value to the Registry
29.2.4.Save user prefs to registry
29.2.5.delete a key from Registry
29.2.6.Delete a setting in Registry