private void Test()
        {
            string file = "ip_settings.ini";

            //写入/更新键值
            INIOperation.INIWriteValue(file, "Desktop", "Color", "Red");
            INIOperation.INIWriteValue(file, "Desktop", "Width", "3270");

            INIOperation.INIWriteValue(file, "Toolbar", "Items", "Save,Delete,Open");
            INIOperation.INIWriteValue(file, "Toolbar", "Dock", "True");

            //写入一批键值
            INIOperation.INIWriteItems(file, "Menu", "File=文件\0View=视图\0Edit=编辑");

            //获取文件中所有的节点
            string[] sections = INIOperation.INIGetAllSectionNames(file);

            //获取指定节点中的所有项
            string[] items = INIOperation.INIGetAllItems(file, "Menu");

            //获取指定节点中所有的键
            string[] keys = INIOperation.INIGetAllItemKeys(file, "Menu");

            //获取指定KEY的值
            string value = INIOperation.INIGetStringValue(file, "Desktop", "color", "");

            //删除指定的KEY
            INIOperation.INIDeleteKey(file, "desktop", "color");

            //删除指定的节点
            INIOperation.INIDeleteSection(file, "desktop");

            //清空指定的节点
            INIOperation.INIEmptySection(file, "toolbar");
        }
Exemple #2
0
        private void InitTree_FromConfig()
        {
            //TreeNode node = new TreeNode("base1");
            //TreeNode node2 = new TreeNode("base2");
            //treeView1.Nodes.Add(node);
            //treeView1.Nodes.Add(node2);
            //node.Nodes.Add("a");
            //node.Nodes.Add("b");
            //node.Nodes.Add("c");
            //node2.Nodes.Add("d");
            //node2.Nodes.Add("e");
            //node2.Nodes.Add("f");
            LogHelper.Debug(this.GetType(), "开始读取配置文件中配置方案信息。。。");
            string sectionsname = "";
            string groupname    = "";

            string[]        sections   = INIOperation.INIGetAllSectionNames(file);
            List <string>   group      = new List <string>();
            List <TreeNode> group_node = new List <TreeNode>();
            TreeNode        node       = null;
            int             count;

            for (int i = 0; i < sections.Length; i++)
            {
                sectionsname = sections[i];
                LogHelper.Debug(this.GetType(), "设置父节点名称为“当前配置”。。。");
                groupname = INIOperation.INIGetStringValue(file, sectionsname, "group", "当前配置");
                if (group.IndexOf(groupname) < 0)
                {
                    group.Add(groupname);
                    node = new TreeNode(groupname);
                    treeView1.Nodes.Add(node);
                    group_node.Add(node);
                }
                count = group.IndexOf(groupname);
                group_node[count].Nodes.Add(sectionsname);
            }
            LogHelper.Debug(this.GetType(), "完成读取配置文件中配置方案信息。。。");
            treeView1.Sort();
        }