Read ini file which does not have any section?

本秂侑毒 提交于 2019-12-06 03:49:35

Here's a library that the author says supports section-less keys. I myself have not tried this library.
Or, you could simply edit the Ini file and add in a "header"/section name right at the top, then delete it once you're done reading.

dtb

Using File.ReadLines and some LINQ is actually not that bad:

var dict = File.ReadLines("config.txt")
               .Where(line => !string.IsNullOrWhiteSpace(line))
               .Select(line => line.Split(new char[] { '=' }, 2, 0))
               .ToDictionary(parts => parts[0], parts => parts[1]);

var result = dict["com.ibm.rcp.toolbox.admin/toolboxvisibleChild"];
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!