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);

     
  • 相关阅读:
    解决maven无法下载jar的问题
    Vue-Router 基础
    VUE自定义组件
    VUE过滤器
    VUE生命周期函数
    VUE表单输入绑定
    VUE计算属性和监听器
    VUE 模板语法
    VUE介绍
    taro3.x: 函数组件createIntersectionObserver
  • 原文地址:https://www.cnblogs.com/provedl/p/14452784.html
Copyright © 2011-2022 走看看