c# - 使用设置文件时出错。

标签 c# settings

我正在尝试使用 VS 2013 中的设置文件来存储 textBox1.Text 的文本,然后在您再次打开应用程序时重新输入它。

我是这样设置的。

设置文件在这里:http://i.gyazo.com/e3aef293c3b8dbdfab269718de81a310.png

在 public Form1() 上,我有这个来阅读文本。

    textBox1.Text = Properties.Settings.Default.aaa;

然后在保存时我就这样了。

    if (checkBox1.Checked)
    {
        Properties.Settings.Default.aaa = textBox1.Text;
    }

但是我得到了错误

 'WindowsFormsApplication1.Properties.Settings' does not contain a definition for 'aaa' and no extension method 'aaa' accepting a first argument of type 'WindowsFormsApplication1.Properties.Settings' could be found (are you missing a using directive or an assembly reference?)

感谢您的帮助。

最佳答案

我遇到了这个问题。问题是 Settings.settings 同时存在于 Properties 文件夹和根文件夹中。我用另一个替换了 Properties 文件夹中的一个。我认为如果您卸载并重新加载项目,可能会出现此问题。

关于c# - 使用设置文件时出错。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24354946/

相关文章:

c# - .net c# <a href> 链接,在正确位置时终止链接

c# - 为什么 Exception 是一个类,而不是一个结构?

git - Git Server 上的域名更改

macos - 使用化妆同步 macos 设置

visual-studio-code - vs代码: incredibly laggy terminal (on mac)

c# - 如何在计算机之间同步我的 Resharper 设置?

C#:自定义控件每隔一次单击调用一次单击处理程序(winform,不是 ASP)

c# - 更新 ItemsSource 后 WPF ComboBox 设置为 null

c# - WinRT XAML 文本框、SelectionStart 和 CR/LF

jenkins - 如何导出/导入 Jenkins 配置?