C# 读取和写入INI配置文件

上传:power1439 浏览: 20 推荐: 0 文件:CS 大小:7.55KB 上传时间:2021-04-07 05:34:54 版权申诉
读取和写入INI配置文件,熟肉下载即可食用。 private static IniFile _file; private static void Test() { string strPath = AppDomain.CurrentDomain.BaseDirectory; //初始化文件 _file = new IniFile(strPath + "config.ini"); //表示为读取CONFIG节点下AAA字段的值(在没有取得数据时默认值为NONE) //同理可以读取任意节点下任意字段的值 string readStr = _file.ReadString("CONFIG", "AAA", "NONE"); //表示为写入CONFIG节点下BBB字段的值 //同理可以写入任意节点下任意字段的值 _file.WriteString("CONFIG", "BBB", "NONE"); //表示为删除CONFIG节点下CCC字段 //同理可以删除任意节点下的任意字段 _file.DeleteKey("CONFIG", "CCC"); }
上传资源
用户评论