Saving a string to a .setting variable

南楼画角 提交于 2019-12-02 11:58:25

问题


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


回答1:


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

:)




回答2:


You must call ...

Properties.Settings.Default.Save();

Check out Using Settings in C#.



来源:https://stackoverflow.com/questions/1283270/saving-a-string-to-a-setting-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!