我正在尝试使用 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/