在哪里存储用户的界面选择?

发布于 2024-09-11 07:06:21 字数 151 浏览 11 评论 0原文

存储界面选择(例如“不再显示此消息”设置)以及用户的任何其他特定于界面的选择的广泛接受的方式是什么?注册表?设置文件?我还可以将它们存储在数据库中,因为我的程序已经可以访问数据库了。

编辑 我当前的程序是本地的,但将来我想将其基于网络。

What is the widely-accepted way to store interface choices, such as 'Do not show this message again' settings, and any other interface-specific choices of the user? Registry? Settings files? I can also store them in a database, since my program already has access to one.

EDITS
My current program is local, however in the future I would like to make it web-based.

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

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

发布评论

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

评论(8

热情消退 2024-09-18 07:06:27

您可以将它们存放在最方便的地方。

在数据库中 - 如果数据库是远程的,您不需要访问本地文件存储,但这确实意味着如果没有连接,您将无法访问首选项。

在注册表中 - 您需要确保您正在使用 CURRENT_USER 区域,以便用户可以实际写入它。 Windows 特定。

在文件中 - 本地存储意味着您不依赖于数据库连接,但您再次需要确保用户有权访问要将文件保存到的文件夹。 C#/.NET 提供了用于读取和写入用户设置文件的类,因此这可能是您的最佳选择。

You can store them where ever it's most convenient.

In the database - if the database is remote you don't need access to the local file store, but it does mean that if the connection's not there you can't access the preferences.

In the registry - you need to make sure that you are using the CURRENT_USER area so that the user can actually write to it. Windows specific.

In a file - storing locally means that you're not relying on the connection to the database, but again you need to make sure that the user has rights to the folder you want to save the file to. C#/.NET provide classes for reading and writing user settings files so this is probably your best choice.

五里雾 2024-09-18 07:06:27

它通常由 Windows 通过 API 进行处理。有关如何:编程异常消息框的 MSDN 文章介绍了如何操作它与.NET。根据该文章,如果您想以这种方式永久存储决策,则异常会存储在注册表中。

您还可以将决策存储在自定义 XML 配置文件中,使用应用程序设置文件来存储它,或者存储在数据库中。由您决定最简单的实现和最少的麻烦。

新的推荐方法是将其存储在用户的应用程序数据目录下。请参阅 Technet 上的数据和设置管理

It is typically handled by Windows via API. MSDN article on How to: Program Exception Message Box explains how to do it with .NET. According to the article, the exception is stored in the registry if you want to store the decision permanently in that manner.

You can also store the decision in a custom XML config file, use your Application Settings file to store it, or in a database. It is up to you on the simplest implementation and least headaches.

The new recommended way is to store it under the User's Application Data directory. See Data and Settings Management at Technet.

错爱 2024-09-18 07:06:27

在 Windows 上,“新”方法是将配置存储在用户的“App-Data”(CS​​IDL_APPDATA) 文件夹中。

On Windows, the "new" way is to store the configurations in the user's "App-Data" (CSIDL_APPDATA) folder.

李不 2024-09-18 07:06:27

我的建议是存储在应用程序安装或 App_Data 中的文件(INI、设置等)。将其存储在注册表中绝对是一种流行的方法,但是当它不再相关时清理它似乎并不那么流行。因此,如果您决定使用注册表,请在需要时自行清理(卸载、注册表项结构更改等)

My recommendation would be a file (INI, Settings, etc.) stored in the application installation, or in App_Data. Storing it in the Registry is definitely a popular way to do it, but cleaning it up when it's no longer relevant doesn't seem to be so popular. So if you decide to use the registry, make an effort to clean up after yourself if needed (uninstall, registry entry structure change, etc.)

温柔嚣张 2024-09-18 07:06:27

我已将各个用户设置存储在使用特定于位置的数据库的 WinfForms 应用程序的数据库中。这很有效,因为当用户登录到不同的客户端计算机时,他们的显示设置也会随之移动。

I have stored individual user settings in the database for a WinfForms application that used a location specific database. This worked nice because as users logged in on different client machines, their display settings moved along with them.

╰沐子 2024-09-18 07:06:26

非基于网络的程序:

我不会使用数据库。如果您决定切换数据库会发生什么?现在您必须迁移用户数据。如果他们卸载会发生什么?

在 Windows 中,用户的 AppData 文件夹中的设置文件是合适的。卸载时不删除它们也是可以接受的,因此设置将持续存在。我会回避用户设置的注册表。该区域更适合系统设置。

*nix 系统中也有类似的区域,但我不确定。已经太久了。


具有本地设置的基于网络的程序:

Cookie 几乎是基于网络的程序的唯一特定于计算机的选项。基于 IP 的过滤器不是一个好主意,因为大多数消费者互联网选项都会每天到每周轮换一次 IP。您可以进行 MAC 过滤,但这需要使用原始套接字来获取 MAC 地址。即便如此,您最终可能会得到路由器的地址,而不是计算机的地址。这意味着同一路由器上的两个人将获得相同的设置。


具有全局设置的基于 Web 的程序:

您的程序应该为此查询 Web 服务。然后,该服务可以自由地以当时最好的方式实施。数据库适合这种情况,因为您的用户数据可能已经存在并且已键入其中,从而提供了一种将数据与特定用户关联的简单方法。

A non-web-based program:

I wouldn't use a database. What happens if you decide to switch the database? Now you have to migrate the user data. What happens if they uninstall?

In Windows, settings files in the user's AppData folder are appropriate. It's also acceptable to not delete these on uninstall, so the settings will persist across that. I would shy away from the registry for user settings. That area is more appropriate for system settings.

There's a similar area in *nix systems, but I'm not sure off the top of my head. It's been too long.


A web-based program with local settings:

Cookies are pretty much the only computer-specific option for a web-based program. IP-based filters are a bad idea, since most consumer internet options will rotate IPs once a day to once a week. You could MAC filter, but that would involve using raw sockets to get the MAC address. And even then, you will probably end up with the address of a router, not a computer. Meaning two people on a single router would get the same settings.


A web-based program with global settings:

Your program should query a web service for this. The service is then free to implement it in whichever way is best at the time. A database is fitting in this scenario, as it's likely that your user data already exists and is keyed therein, providing an easy way to associate data with particular users.

星軌x 2024-09-18 07:06:26

如果是与Web相关的环境:
取决于您希望他们停留多长时间。如果数据库中有会员注册,那么将其保存在数据库中是完全有意义的。否则,您可以将其保存为数据库中的 cookie 或 ip/设置。

if its a Web-related Environment:
depends on how long you want them to stay. If there is a member registration within a database it would totally make sense to save it in the database. Else you could just save it as a cookie or ip/setting in a database.

被你宠の有点坏 2024-09-18 07:06:26

假设您指的是 Windows 应用程序,.NET 应用程序设置 功能默认情况下使用文件系统(尽管您可以使用注册表或其他任何东西,因为它是可插入的)。

Assuming you mean on a Windows application, the .NET Application Settings feature uses the filesystem by default (though you can use the registry or anything else, as it's pluggable).

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