文档详情

在 .NET 框架中保留应用程序设置.docx

发布:2015-10-03约3.38万字共43页下载文档
文本预览下载声明
在 .NET 框架中保留应用程序设置 Jeff Danner Microsoft Corporation 2002 年 6 月 摘要:本文介绍在 Microsoft .NET 框架中,如何通过将应用程序设置保存到注册表中或将其序列化到配置文件中,在运行时保留应用程序设置。本文包含一些指向英文站点的链接。 目录  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_topic1 \t _self 简介  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_topic2 \t _self 保存应用程序设置的前提  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_topic3 \t _self 使用注册表存储数据  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_savingdata \t _self 将数据保存到注册表  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_retrievingdata \t _self 从注册表检索数据  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_creatingcustomclass \t _self 创建自定义应用程序配置类  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_topic4 \t _self 将应用程序设置类用于应用程序  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_loadingsettings \t _self 加载保存的应用程序设置  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_savingsettings \t _self 保存应用程序设置  HYPERLINK /china/MSDN/library/archives/library/dndotnet/html/persistappsettnet.asp \l persistappsettnet_topic5 \t _self 小结 简介 保存应用程序设置是一项常见任务。过去??我们通常将设置保存到 INI 文件或注册表中。而在 Microsoft? .NET 框架中,我们多了另一种选择,即将应用程序设置序列化到 XML 文件中,以便轻松地更新和检索这些设置。Microsoft Visual Studio? .NET 使用 System.Configuration.AppSettingsReader 类读取存储在配置文件中的 DynamicProperties。但是,这些动态属性在运行时是只读的,因此您无法保留用户所做的更改。本文将介绍如何序列化数据并将其写入一个文件,以及如何读取和反序列化该数据。存储数据的方式和位置取决于要存储的内容,本文将讨论如何根据数据类型将其存储到相应的位置。 保存应用程序设置的前提 Windows 窗体 Application 类包含多个属性,允许您轻松导航到注册表或用户数据文件夹的相应部分。要正确使用这些属性,您必须设置 AssemblyCompany、AssemblyProduct 和 AssemblyVersio
显示全部
相似文档