SamKr
12/2/2014 - 9:08 AM

Registry

Registry

const string appKeyString = @"SOFTWARE\CompanyName";
RegistryKey appRootKey = Registry.CurrentUser.CreateSubKey(appKeyString);
RegistryKey configKey = appRootKey.CreateSubKey("KeyName");
configKey.SetValue("ValueName", "Value", RegistryValueKind.String);
configKey.Flush();
RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\CompanyName\KeyName", false);
String temp = (string)regKey.GetValue("ValueName");

if (string.IsNullOrEmpty(temp)) { temp = "default"; }