CreateSubKey不在当前用户中创建条目

时间:2016-11-06 06:46:46

标签: c# windows registrykey

我正在尝试在当前用户下创建子密钥,应用程序成功运行,但无法在当前用户下创建子密钥。以下是我的应用程序逻辑。谁能告诉我我在这里做了什么错误?

RegistryKey myAppSettings = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\MyAppSettings");

Console.WriteLine(myAppSettings);
//storing the values  
myAppSettings.SetValue("appName", "C# Tutorials");
myAppSettings.SetValue("Demo", "Registry keys storage");


myAppSettings.Close();

1 个答案:

答案 0 :(得分:-1)

CreateSubkey不适用于路径值。您必须打开RegistryKey“软件”并为其创建子项。