zoukankan      html  css  js  c++  java
  • c# 读取web.config(xml)文件并进行修改

    web config 配置如下:
             <add key="ewnhUrl" value="192.168.0.1" />
      
    读取文件并修改

    XmlDocument xml = new XmlDocument();
    //路径
    var ConfigPathew = rootPath + "\dddl\Configs\system.config"; xml.Load(ConfigPathew); XmlNodeList nodesew = xml.GetElementsByTagName("add"); for (int i = 0; i < nodesew.Count; i++) { XmlAttribute attew = nodesew[i].Attributes["value"]; if (attew != null) { if (nodesew[i].Attributes[0].Value == "ewnhUrl") { attew = nodesew[i].Attributes["value"];
                  //要写入的文本 attew.Value
    = ExtranetIp.Text + ":" + port; break; } } } xml.Save(ConfigPathew);



      //为当前文件夹赋予everyone权限
      string rootPath = Directory.GetCurrentDirectory();
      DirectorySecurity fsec = new DirectorySecurity();
      fsec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl,
      InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
      System.IO.Directory.SetAccessControl(rootPath, fsec);

     
  • 相关阅读:
    黑盒测试用例设计方法
    摄像头--用例设计
    单元测试框架unittest
    ES集群启动流程
    ES 系统模型
    HBase 体系结构
    HBase 数据模型
    引用中间件导致的OOM问题调查
    BeanDefinition注册逻辑解析
    spring xml 解析bean配置文件为beanDefinition过程
  • 原文地址:https://www.cnblogs.com/provedl/p/14452784.html
Copyright © 2011-2022 走看看