How to save user.config to AppData\Roaming folder instead of AppData\Local?

前端 未结 2 2070
时光取名叫无心
时光取名叫无心 2020-12-23 22:09

Introductory Example

This code

Properties.Settings.Default.MyUserSettingBlah = \"some new value\";
Properties.Settings.Default.Save(         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-23 23:07

    I don't know if it's a new feature or not, but in VS2010 every setting has a property called Roaming that can be set to true or false.
    It's not visible in the Settings designer though, you have to set it in the properties window for the setting you'd like to use it on.

    Setting that property to true on a setting adds

    [global::System.Configuration.SettingsManageabilityAttribute(global::System.Configuration.SettingsManageability.Roaming)]

    to Settings.Designer.cs for that particular setting, which is almost identical to what Ivan suggested.

提交回复
热议问题