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

     
  • 相关阅读:
    数据可视化
    tkinter学习04
    小练习-----银行提款机系统
    python___docx模块
    Django【进阶篇 】
    Django之Cookie/session/防止XSS攻击
    tkinter学习03
    tkinter学习02
    AJAX
    tkinter学习01
  • 原文地址:https://www.cnblogs.com/provedl/p/14452784.html
Copyright © 2011-2022 走看看