Saving a string to a .setting variable

2020-04-20 11:54发布

I'm trying to save a string variable from my FolderBrowserDialog.SelectedPath().

Using a breakpoint I can see that the string is correctly loaded onto SelectedPath(), but I can't save that string to the .settings file for the life of me. Any help?

    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();
            }
        }
    }

The setting WoWFolderLocation is string type, and is a User scope setting. What am I doing wrong? :P

2条回答
我想做一个坏孩纸
2楼-- · 2020-04-20 12:33

You need to call Properties.Settings.Default.Save().

:)

查看更多
Luminary・发光体
3楼-- · 2020-04-20 12:44

You must call ...

Properties.Settings.Default.Save();

Check out Using Settings in C#.

查看更多
登录 后发表回答