zoukankan      html  css  js  c++  java
  • App.config 读、写

            /// <summary>
            /// 读
            /// </summary>
            /// <returns></returns>
            public string GetFolderPath() {
                FolderPath = ConfigurationSettings.AppSettings["folderPath"];
                return FolderPath;
            }
            /// <summary>
            /// 写
            /// </summary>
            public void SetFolderPath(string folderPath) {
                if (String.IsNullOrEmpty(folderPath)) return;
    
                string fullPath =@"E:\aa\App.config";
                if (!System.IO.File.Exists(fullPath)) {
                    System.Windows.Forms.MessageBox.Show(fullPath + "文档不存在!");
                    return;
                }
                XmlDocument doc = new XmlDocument();
                doc.Load(fullPath);
                XmlNodeList nodes = doc.GetElementsByTagName("add");
                for (int i = 0; i < nodes.Count; i++) {
                    XmlAttribute att = nodes[i].Attributes["key"];
                    if (att.Value == "folderPath") {
                        nodes[i].Attributes["value"].Value = folderPath;
                        break;
                    }
                }
                doc.Save(fullPath);
            }
  • 相关阅读:
    visual sudio开发工具使用小技巧
    JS去除右边的逗号
    下拉标题
    sp_addextendedproperty
    触发器的使用
    缺失一个正数
    组合总和 去重
    拖动 Drag
    n皇后问题
    括号生成
  • 原文地址:https://www.cnblogs.com/chinaniit/p/1467783.html
Copyright © 2011-2022 走看看