保存设置在.NET WinForms应用程序 [英] Save Settings in a .NET Winforms Application
本文介绍了保存设置在.NET WinForms应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/26369/what-is-the-best-way-to-store-user-settings-for-a-net-application\">What是存储用户设置的.NET应用程序的最佳方式?
我已经找到了很多非常不同的例子,至于怎么一会从一个WinForms应用程序保存(每用户)应用程序设置。
I have found alot of VERY different examples as to how one would save application settings (per user) from a Winforms application.
我想,这样做正确的方法是用C#很简单,我希望有人能告诉我吗?
I imagine that the correct way to do this is very simple in c# and am hoping someone can enlighten me?
推荐答案
在某些时候,答案归结为口味的问题。我说你会至少这些选项结束:
At some point, the answer boils down to a matter of taste. I'd say you'll end up with at least these options:
- 它存储在注册表,那就是你有HKEY_CURRENT_USER项。根据它的一切是用户特定的。当你想储存一大堆小键 - 值对的这通常是preferred。该系统的主要优点是,你的设置很容易查找和共享在几个不同的应用程序。要沿着这条路走下去,你可以从这里 启动。
- 使用.NET应用程序设置,提供了在运行时访问您的设置最简单的方法。再次,这是对于小规模的数据键 - 值对使用更好的。国际海事组织,这种方法的主要优点是它的简单,它使您能够使用一些.NET类作为值(而不是强迫你一切转换成更基本类型)的事实。要沿着这条路走下去,你可以从这里 启动。
- 将其存储在用户数据文件夹,这通常是用户的配置文件目录下隐藏。这是preferred当你要存储大量数据,或任意数量的文件。这种方法的主要优点是,你可以操纵你的数据,你会与任何文件(也可能是缺点)。要沿着这条路走下去,你可以从<一开始href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.application.userappdatapath.aspx\">here.
- store it in the registry, where you have the HKEY_CURRENT_USER key. Everything under it is user-specific. This is usually preferred when you want to store a bunch of small key-value pairs. The main advantage of this system is that your settings are easy to find and share throughout several different applications. To follow this path, you can start from here.
- using .NET Application settings, provides the easiest way to access your settings at runtime. Again, it's better for using with key-value pairs of small-sized data. IMO, the main advantages of this method is its simplicity and the fact that it empowers you to use some .NET classes as values (not forcing you to convert everything into more basic types). To follow this path, you can start from here.
- store it in User Data folders, which are usually hidden under the user's profile directory. This is preferred when you want to store a large amount of data or any number of files. The main advantage of this method is that you can manipulate your data as you would with any files (that may also be a disadvantage). To follow this path, you can start from here.
这篇关于保存设置在.NET WinForms应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文