When I've deployed a Windows Forms application, how can I change the default settings?

不打扰是莪最后的温柔 提交于 2019-12-12 06:19:28

问题


I've deployed a Windows Forms application. On my local development PC, there is a settings.settings file which contains all the app's settings.

I'm aware as-per this question and others like it, that a User.config file gets created in c:\Users\username\Local Settings\AppData\Local\...

However, I need to change a default setting, so that when users start it for the first time, the default settings are different than when we initially deployed the app.

So the first time a user runs the app, it creates their local copy of the file.

What does it base that on? Is there a default copy of the file somewhere, or is it compiled into the .exe?

I need to get the default settings updated on an app that's deployed on several laptops remotely where I only have telephone support. If I have to recompile and republish then that needs to be as a last resort.


回答1:


Considering this facts may be useful:

  • The default values for user settings are stored in yourapplication.exe.config beside yourapplication.exe
  • Current values for user settings are not in this file and any change in them could be saved using Properties.Default.Settings.Save()
  • If there is no yourapplication.exe.config in your executable folder, it will be created automatically using values in your .settings file.
  • If you call Properties.Default.Settings.Reset() the values in yourapplication.exe.config will be used to override user saved values.
  • Adding a new settings requires recompile and republish.
  • To overcome the pain of update and distribution, you may consider ClickOnce.


来源:https://stackoverflow.com/questions/32522885/when-ive-deployed-a-windows-forms-application-how-can-i-change-the-default-set

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