部署Windows窗体应用程序时,如何更改默认设置? [英] When I've deployed a Windows Forms application, how can I change the default settings?

查看:322
本文介绍了部署Windows窗体应用程序时,如何更改默认设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我部署了一个Windows窗体应用程序。在我的本地开发PC上,有一个 settings.settings 文件,其中包含所有应用程序的设置。



m知道这个问题和其他人喜欢它,一个User.config文件创建在 c:\Users\username\Local Settings\AppData\Local\ ...



但是,我需要更改默认设置,以便用户第一次启动时,默认设置与我们最初部署了该应用程序。



所以用户第一次运行该应用程序时,会创建该文件的本地副本。



它是以什么为基础的?有没有文件的默认副本在某个地方,或者是编译到.exe?



我需要获得在部署在几台笔记本电脑上的应用程序更新的默认设置远程我只有电话支持。

解决方案

考虑到这些事实可能是有用的: / p>


  • 用户设置的默认值存储在 yourapplication.exe.config code> yourapplication.exe

  • 用户设置的当前值不在此文件中,任何更改都可以使用 Properties.Default.Settings.Save()

  • 如果没有 yourapplication.exe.config 在您的可执行文件夹中,将使用 .settings 文件中的值自动创建。

  • 如果调用 Properties.Default.Settings.Reset() yourapplication.exe.config 中的值将用于覆盖用户保存的值。

  • 添加新设置需要重新编译并重新发布。

  • 为了克服更新和分发的痛苦,您可以考虑ClickOnce。


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.

解决方案

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.

这篇关于部署Windows窗体应用程序时,如何更改默认设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆