zoukankan      html  css  js  c++  java
  • 读写WebConfig

    Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
    ConnectionStringsSection cnnSection = (ConnectionStringsSection)config.GetSection("connectionStrings");
     cnnSection.ConnectionStrings.Clear();
     cnnSection.ConnectionStrings.Add(new System.Configuration.ConnectionStringSettings("SQL SERVER", value, "System.Data.SqlClient"));
     config.Save();

    第一个函数的参数是webconfig的位置,如果为null是framwork的根目录下的webconfig,当然默认是没有权限去更改的,这里的“~”意思是当前程序的根目录。当然如果为了保险还可以加入一些权限控制的东西。

    作者:KKcat
        
    个人博客:http://jinzhao.me/
        
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    python shutil
    AttributeError: module 'shutil' has no attribute 'copyfileobj'
    python configparser
    JSON使用
    VRRP
    KeepAlived的介绍
    Nginx模块
    Nginx配置
    Nginx介绍
    apache相关补充
  • 原文地址:https://www.cnblogs.com/jinzhao/p/1395996.html
Copyright © 2011-2022 走看看