在给定的 C# Windows 窗体应用程序/WPF 中,用户设置通常存储在哪里?

发布于 2024-09-01 21:58:38 字数 131 浏览 3 评论 0原文

我在想:

  1. 一个Appconfig文件

  2. 一个通用的.XML文件,并在启动时具有程序加载值。

最好的方法是什么?也许是一个拥有最佳用户教程的网站?

I was thinking either:

  1. An Appconfig file

  2. A generic .XML file and have the program load values at launch.

What is the best way to do this? A website with a best user tutorial perhaps?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烂人 2024-09-08 21:58:38

请参阅在 C# 中使用设置

.NET Framework 2.0 允许您
创造并获取价值
在应用程序之间持续存在
执行会话。这些值是
称为设置。设置即可
代表用户偏好,或
有价值的应用信息
需要使用。例如,您可能
创建一系列存储的设置
用户对配色方案的偏好
一个应用程序的。或者你可以存储
指定的连接字符串
您的应用程序使用的数据库。
设置允许你们都坚持
对以下事项至关重要的信息
代码之外的应用程序,以及
创建存储配置文件
个人用户的偏好。

Please see Using Settings in C#:

The .NET Framework 2.0 allows you to
create and access values that are
persisted between application
execution sessions. These values are
called settings. Settings can
represent user preferences, or
valuable information the application
needs to use. For example, you might
create a series of settings that store
user preferences for the color scheme
of an application. Or you might store
the connection string that specifies a
database that your application uses.
Settings allow you to both persist
information that is critical to the
application outside of the code, and
to create profiles that store the
preferences of individual users.

音盲 2024-09-08 21:58:38

您的问题的答案取决于设置的持久性模型:

  • 设置是基于每个用户的还是基于计算机范围的?
  • 设置是特定于应用程序的还是可以/是否需要由其他应用程序使用/发现?
  • 设置默认值是在设计时已知的还是在安装时生成的?
  • 设置是特定计算机的本地设置还是可以/将会漫游?

标准 .NET 设置 支持本地 Per-用户设置(当用户作为普通用户运行时)和本地计算机范围设置(当用户作为管理员运行时),两者都具有构建时计算机范围默认值并且仅供应用程序使用。这解决了大多数场景。那里有一些高级功能,允许将 .NET Configuration 类与不同位置的配置文件一起使用,这也可以允许可漫游和第三方可发现的设置;但是,Visual Studio 工具不支持此类场景。

The answer to your question depends on the persistence model for the settings:

  • are settings per-user based or machine-wide?
  • are settings application specific or can/do they need to be used/discovered by other applications as well?
  • are settings default values known at design time or are they generated at install time?
  • are settings local to particular machine or can/will they be roamed?

The standard .NET settings support local per-user settings (when the user runs as a regular user) and local machine-wide settings (when the user runs as administrator), both with build-time machine-wide default values and for application-use only. This addresses the majority of scenarios. There is some advanced functionality there which allows to use the .NET Configuration classes with configuration files in different locations, which can allow for roamable and third-party discoverable settings as well; however, there is no Visual Studio tooling support for such scenarios.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文