Saving setting to a exe

笑着哭i 提交于 2019-12-06 14:17:24

MSDN explicit says something about this:

Settings that are application-scoped are read-only, and can only be changed at design time or by altering the .config file in between application sessions. Settings that are user-scoped, however, can be written at run time just as you would change any property value. The new value persists for the duration of the application session. You can persist the changes to the settings between application sessions by calling the Save method.

For this, Application setting will never work for you. However, if you are using a User scoped settings it does work, but soon you change the application from one computer to another (as you say you want to) you will loose the settings as that's another machine (another user-scope)...

There are way to continue to have the same settings, you can do, at least 2 things:

  • use a .config file to save the settings (it's an XML file)
  • use a service to host the settings and you can read if user has internet access

What you can't do is

  • using only one executable file, save the settings from computer to computer.

User settings are compiled differently than Application settings, and thus cannot be converted after compilation. Why not compile with Application Settings?

The code you are using should save the user settings. Rememeber that user settings will be saved in the user's data folder. Not in the configuration file where the app was installed (say program files). This is the usual path:

<Profile Directory>\<Company Name>\<App Name>_<Evidence Type>_<Evidence Hash>\<Version>\user.config

See this links form more information

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