.NET 应用程序/用户设置问题

发布于 2024-10-09 03:12:58 字数 426 浏览 0 评论 0原文

有人可以向我解释一下应用程序和用户设置及其差异吗?我有一个只有一个人会使用的 C# 应用程序。用户可以在程序中设置一些首选项,我通过用户范围的设置实现了这些首选项。我的印象是用户范围的设置能够在运行时读取和写入,事实确实如此。但他们没有坚持。一旦应用程序关闭并重新打开,噗的一声,所有用户的设置都消失了。

应用程序设置似乎更适合我正在做的事情,只是它们不能在运行时进行操作。

那么...

问题#1:用户范围的设置是否应该持续存在?

问题#2:用户和应用程序范围之间的区别是否在于应用程序无法在运行时更改,但用户可以?

问题 #3:如果我无法使用设置,或者在这种情况下不应该使用设置,那么保存偏好设置的替代建议是什么?

Could someone please explain application and user settings, and their differences to me? I've got a C# application that only ONE person will use. There are preferences the user can set within the program, and I implemented these preferences with user-scoped settings. I was under the impression user-scoped settings would be able to be read and written at runtime, which they are. But they are not persisting. Once the application is closed and reopened, poof, there go all the user's settings.

Application settings seem to be a better fit for what I'm doing, except they can't be manipulated at runtime.

So...

Question #1: Are user-scoped settings suppose to persist?

Question #2: Is the difference between user and application scope the fact that application cannot be changed at runtime, but user can?

Question #3: If I can't use settings, or shouldn't in this case, what would alternative suggestions for saving preferences be?

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

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

发布评论

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

评论(1

痴情 2024-10-16 03:12:58

此处提供了一些不错的信息。

  1. 是的。确保您在某个时刻对它们调用 Save() 函数!通常与Settings.Default.Save()一起使用。
  2. 是的,但不是。我相信从技术上讲,您可以在运行时更改并保留应用程序设置,但实际上并非如此,因为大多数部署机制都会阻止这样做,因为您的安装文件夹应该是只读的。
  3. 不适用。使用设置!你走在正确的轨道上。如果您发现需要保存大量信息,那么您可能需要查看更丰富的数据存储 - 例如 XML、SQL、SQL-CE 等。

There's some good information here.

  1. Yes. Make sure you're calling the Save() function on them at some point! Usually with Settings.Default.Save().
  2. Yes, but no. I believe that technically you can change and persist application settings at runtime, but not really because most deployment mechanisms prevent this because your installation folder should be read only.
  3. N/A. Use the settings! You're on the right track. If you find you need to persist loads of information then you might need to look at richer data stores - e.g. XML, SQL, SQL-CE, etc.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文