问题
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
besideyourapplication.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 inyourapplication.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