Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        private void Button5_Click(object sender, EventArgs e)
        {
            string sectionname;

            if (treeView1.SelectedNode != null)
            {
                sectionname = treeView1.SelectedNode.Text;
                treeView1.SelectedNode.Remove();
                INIOperation.INIDeleteSection(file, sectionname);
                treeView1.SelectedNode = null;
                MessageBox.Show("方案【" + sectionname + "】删除成功!");
            }
            else
            {
                MessageBox.Show("请选择要删除的方案名称!");
            }
        }