ConfigurationSettings.AppSettings[""] 只是程序初始化的时候获得数据,之后不再从config文件获得。直接使用的是初始化获得的数据。Confile文件的格式大致是这样的:
<?xml version="1.0" encoding="Windows-1252"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="lblValue.Text" value="(empty)" />
<add key="hello" value="good" />
</appSettings>
</configuration>
用的的类有AppSettings和AppSetting类
AppSettings里的函数:Save,Add,RemoveByKey
下面是MS例子里的说明文档:
.NET Framework: Configuration Settings
This sample demonstrates howto read and write to an application's configuration fileappSettings section.
Featured Highlights
.NET applications support custom XML configuration files out-of-the box. You simply add an app.config file to your solution via Project | Add New Item and selectthe Application Configuration File option. The item will be added to your bin directory each time you compile. You can then add your own settings to this file so that users or administrators can adjust an application's settings by simply adjusting a text file.
You can specifiy settings for individual controls that you want exposed via the configuration file. You simply add a Dynamic Property for any control value you want exposed. Examine the lblValue control for an example. Any of the dynamic property values defined in the appSettings section of configuration file will be loaded at runtime. You can access the values via the ConfigurationSettings.AppSettings. However, the NameValueCollection object exposed is read only. In addition, the settings are only loaded once at application startup.
If you want to be able to make changes to the file at runtime, you will need use the classes in the System.Xml namespace. This sample exposes two classes to let you do this:
- AppSettings which wraps the configuration file's appSettings section
- AppSetting which represents a single name/value pair item
AppSettings allows you to add, retrieve, update, and remove name/value pairs from the configuration file. It does this by wrapping access to the file via an XmlDocument instance.In addition it supports saving the changes manually or via an auto-save feature. Finally, the class implements IEnumerable to provide For..Each support.
Requirements
Requires the Trial or Release version of Visual Studio .NET Professional (or greater).
Running the Sample
Start the program and examine the data exposed. Change the file manually and then use the functions on the Custom tab to see the changes. Or, use the command options exposed under the Custom tab.
分享到:
相关推荐
AForge.NET Framework-2.2.5-Samples-Docs-Sources.zip 从官网下载的哈,最新,最全。
These samples demonstrate many of the new features available with Visual Basic 2008 and the .NET Framework 3.5 including hundreds Language Integrated Query (LINQ) samples. The following is the list ...
很多常用的Linq写法,基于Vb.net,本人收获良多 LinqSamples LinqToSQLSamples LinqToXMLSamples LinqToDataSetSamples 举例:Linq to sql Dim categories = From prod In db.Products _ Group By Key = New With ...
本主题将围绕"vb.net 串口源码"这个主题,深入探讨如何在VB.NET中进行串口编程,并结合提供的压缩包文件,解析其中可能包含的示例代码。 1. **串口基础概念** - 串口通信:串口是一种串行通信接口,通过数据位、...
vuforia-samples-advanced-android-ios-unity-4-2-3.zip官网下载太慢了,放在网盘方便大家下载
Tested were hundreds of Microsoft sample projects (101 VB.Net samples, DirectX samples, etc.), in house and customer projects, third party control samples (Infragistics, ComponentOne, Telerik, etc.),...
微软出版 “101 Microsoft® Visual Basic® .NET Applications” 的配套代码。比较老的东东,难度覆盖入门到中等的技巧。
在VB .NET编程环境中,Ribbon样式是一种设计用户界面的方式,它模仿了Microsoft Office的现代风格,提供了一种直观且高效的交互方式。本资源包含了一个关于如何在VB .NET中实现Ribbon样式的实例,源自国外的专业分享...
《MiniGUI开发示例库详解——mg-samples-1.6.0》 MiniGUI,全称微型图形用户界面,是一种轻量级的图形系统,主要用于嵌入式设备和资源有限的计算机上,提供图形用户界面的支持。它以其小巧、高效、易用的特点在...
Android官方提供的`architecture-samples-todo-mvp`示例项目旨在帮助开发者理解和实践MVP架构。 **1. MVP架构的组成部分** - **Model(模型层)**:模型层主要负责与数据相关的操作,包括数据的获取、存储和处理。...
《海思3521A平台上的Minigui移植与应用——mg-samples-3.2.2.tar.gz详解》 Minigui是一款轻量级的图形用户界面系统,广泛应用于嵌入式设备和移动设备中。在海思3521A平台上,Minigui的移植对于开发人员来说是一项...
"fo-dicom-samples-master.zip"是一个包含了fo-dicom最新开发示例的压缩包,适用于桌面、iOS和Android平台,是学习和应用fo-dicom的关键资源。 一、fo-dicom核心功能 fo-dicom库的主要功能包括但不限于: 1. DICOM...
【标题】"arcgis-runtime-samples-dotnet-master.zip" 是一个包含ArcGIS Runtime SDK for .NET的示例项目的压缩包,主要用于展示如何在.NET环境中利用ArcGIS运行时库进行地图应用开发。 【描述】提到的“ArcGIS ...
spring-android-samples-master
spring-security-samples-contacts-2.0.4.war
spring的安全框架演示demo,这个是简单的,适合初学者
【samples-gh-pages_SamplesGhPages_】项目是一个用于展示GitHub Pages应用的工作表,它提供了多种示例和教程,帮助用户了解如何有效地利用GitHub Pages服务。GitHub Pages是GitHub提供的一个静态网页托管服务,允许...
在给定的标题和描述中,我们关注的是`mg-samples-str-1.6.2.rar`,这似乎是一个包含MiniGUI示例代码的压缩包,版本为1.6.2。这个压缩包是为那些想要学习和理解MiniGUI工作原理的开发者准备的。 MiniGUI的核心特性...
在"Winforms Samples"这个压缩包中,可能包含了一系列的VB.NET WinForm编程实例,这些实例可以用来学习和实践上述知识点。通过分析和运行这些示例,你可以更深入地理解和掌握VB.NET WinForm编程技术。同时,也可以...
"spring-boot-samples-master"这个项目,正是一个集大成的Spring Boot示例仓库,它包含了各种Spring Boot应用场景的实例代码,帮助开发者深入理解和学习Spring Boot的核心特性和最佳实践。 在深入探讨之前,我们先...