[英]How i can save settings to the application Settings?
I created a new cell called it MySettings 我创建了一个名为MySettings的新单元格
The type is string the scope is user. 类型是字符串,范围是用户。
And in this place i want to store the last selected path: 在这个地方,我想存储最后选择的路径:
private void btnDirectory_Click(object sender, EventArgs e)
{
FolderBrowserDialog MyDialog = new FolderBrowserDialog();
MyDialog.SelectedPath = lblDirectoryName.Text;
if (MyDialog.ShowDialog() == DialogResult.OK)
{
lblDirectoryName.Text = MyDialog.SelectedPath;
}
}
Right after the line 下线后
MyDialog.SelectedPath = lblDirectoryName.Text;
I want to store the MyDialog.SelectedPath to MySettings I tried to type: Properties.Settings. 我想将MyDialog.SelectedPath存储到我尝试键入的MySettings:Properties.Settings。 but i have there some options the first Default.
但是我有一些选择的默认值。 But where is MySettings ?
但是MySettings在哪里?
And where and how i load back the saved settings ? 以及在何处以及如何加载已保存的设置?
if (MyDialog.ShowDialog() == DialogResult.OK)
{
lblDirectoryName.Text = MyDialog.SelectedPath;
Properties.Settings.Default.MySettings=MyDialog.SelectedPath;
Properties.Settings.Default.Save();
}
You can retrieve the store/saved value as following: 您可以按以下方式检索存储/保存的值:
MyDialog.SelectedPath=Properties.Settings.Default.MySettings;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.