C# 如何使用注册表重新填充文本框
在程序停止使用注册表后,如何用以前的文本重新填充文本框 我读过多篇文章,如: 到目前为止,我什么都没有,因为没有任何结果,我得到的只是错误D:C# 如何使用注册表重新填充文本框,c#,visual-studio-2010,registry,C#,Visual Studio 2010,Registry,在程序停止使用注册表后,如何用以前的文本重新填充文本框 我读过多篇文章,如: 到目前为止,我什么都没有,因为没有任何结果,我得到的只是错误D: public string Read(string KeyName) { RegistryKey rk = baseRegistryKey ; RegistryKey sk1 = rk.OpenSubKey(subKey); if ( sk1 == null )
public string Read(string KeyName)
{
RegistryKey rk = baseRegistryKey ;
RegistryKey sk1 = rk.OpenSubKey(subKey);
if ( sk1 == null )
return null;
else
{
try
{
return (string)sk1.GetValue(KeyName.ToUpper());
}
catch (Exception ex)
{
}
}
}
表示baseRegistryKey和subKey不存在。它说RegistryKey不存在。如何修复?我几天前也遇到了同样的问题,不要使用那些瞄准具,它们都很糟糕 您的代码有几处错误:
- baseRegistryKey和subKey需要设置为某种参数
- 如果RegisterKey不起作用,那么您可能没有使用Microsoft.Win32执行
- 我用来解决这个问题的代码是:
public WindowsConsoleForm1(); try { InitializeComponent(); textBox1.Text = Application.UserAppDataRegistry.GetValue("example").ToString(); } catch { }
- 然后在您有的地方,例如:
,在它下面发布textbox1.text=Path.GetDirectoryName(saveFileDialoge1.FileName)
Application.UserAppDataRegistry.SetValue(“示例”,textbox1.text)代码>
- baseRegistryKey和subKey需要设置为某种参数
- 如果RegisterKey不起作用,那么您可能没有使用Microsoft.Win32执行
- 我用来解决这个问题的代码是:
public WindowsConsoleForm1(); try { InitializeComponent(); textBox1.Text = Application.UserAppDataRegistry.GetValue("example").ToString(); } catch { }
- 然后在您有的地方,例如:
,在它下面发布textbox1.text=Path.GetDirectoryName(saveFileDialoge1.FileName)
Application.UserAppDataRegistry.SetValue(“示例”,textbox1.text)代码>
- 几天前我也遇到了同样的问题,不要使用那些瞄准具,它们都很糟糕
您的代码有几处错误: