Posted: 6 years ago

Filed under: .NET

Tagged with: c# configuration

Follow comments

Loading and saving registry information in C#

Saving info to the registry for the currently logged in user:

RegistryKey key = Registry.CurrentUser.CreateSubKey("MyRegistryKey");
key.SetValue("MyKeyValue", "Some value");

Loading the same info from the registry:

RegistryKey key = Registry.CurrentUser.CreateSubKey("MyRegistryKey");
if(key != null) {
    string keyValue = (string) key .GetValue("MyKeyValue");
}

Reference:
RegistryKey Class MSDN documentation

Leave a Reply