.NET 2.0 Configuration配置文件的保存问题



Configuration config  =  ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
TestSection section 
=  config.Sections[ " Test " as  TestSection;
section.UserName 
=   " Vivi " ;
//  在Vistual Studio调试时,config.FilePth是“AppName.vshost.exe.config”;
//  正常运行程序(不是在Visual Studio中按F5启动)时,config.FilePth才是“AppName.exe.config”。
//  所以,这两种不同情况下config.Save();保存到了不同的文件中。
config.Save();            
config.SaveAs(
" myconfig.xml " );
//  执行完上面的语句“config.SaveAs("myconfig.xml");”后,config.FilePth变成了“myconfig.xml”,
//  所以下面的config.Save()仍然是保存配置到myconfig.xml,而不是AppName.exe.config。
config.Save();



from:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_aspnetconfig/html/c282a0c3-0642-458b-8426-565ead922749.htm
 




Scope of Configuration Settings


   

Configuration level

File name

File description

Server

Machine.config

The Machine.config file contains the ASP.NET schema for all of the Web applications on the server. This file is at the top of the configuration merge hierarchy.

Root Web

Web.config

The Web.config file for the server is stored in the same directory as the Machine.config file and contains default values for most of the system.web configuration sections. At run time, this file is merged second from the top in the configuration hierarchy.

Web site

Web.config

The Web.config file for a specific Web site contains settings that apply to the Web site and inherit downward through all of the ASP.NET applications and subdirectories of the site.

ASP.NET application root directory

Web.config

The Web.config file for a specific ASP.NET application is located in the root directory of the application and contains settings that apply to the Web application and inherit downward through all of the subdirectories in its branch.

ASP.NET application
subdirectory

Web.config

The Web.config file for an application subdirectory contains settings that apply to this subdirectory and inherit downward through all of the subdirectories in its branch.

Client application
directory

ApplicationName.config

The ApplicationName.config file contains settings for a Windows client application (not a Web application).



Configuration Structure


ASP.NET configuration files are called Web.config files, and they can appear in multiple directories in ASP.NET applications. The ASP.NET configuration hierarchy has the following characteristics:

转载于:https://www.cnblogs.com/h2appy/archive/2008/06/02/1212291.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值