将字符串保存到.setting变量

时间:2009-08-16 01:26:01

标签: c# settings.settings

我正在尝试从FolderBrowserDialog.SelectedPath()中保存字符串变量。

使用断点我可以看到字符串已正确加载到SelectedPath(),但是我无法将该字符串保存到.settings文件中。有什么帮助吗?

    public void LocateWoWFolder()
    {
        using (FolderBrowserDialog FileDialogWindow = new FolderBrowserDialog())
        {
            if (FileDialogWindow.ShowDialog() == DialogResult.OK)
            {
                //Using a breakpoint here I can see that nothing is loaded to .WoWFolderLocation.
                Properties.Settings.Default.WoWFolderLocation = FileDialogWindow.SelectedPath.ToString();
            }
        }
    }

设置WoWFolderLocation是字符串类型,是用户范围设置。我究竟做错了什么? :P

2 个答案:

答案 0 :(得分:6)

您需要致电Properties.Settings.Default.Save()

:)

答案 1 :(得分:2)

你必须打电话......

Properties.Settings.Default.Save();

查看Using Settings in C#