读ini文件没有任何节吗? [英] Read ini file which does not have any section?

查看:219
本文介绍了读ini文件没有任何节吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ini文件没有任何节。它具有以下数据

 
com.ibm.rcp.toolbox.admin / toolboxvisibleChild = false
com.ibm.collaboration.realtime .community / defaultAuthType = ST-DOMINO-SSO
com.ibm.collaboration.realtime.brokerbridge / startBroker = false
com.ibm.collaboration.realtime.webapi / startWebContainer = true

我想使用函数。

  [DllImport( kernel32)] 
私有静态外部int GetPrivateProfileString(字符串部分,
字符串键,字符串def,StringBuilder retVal,
int大小,字符串filePath);

我的问题


  1. 由于没有任何内容,我无法在函数中提供节名

  2. 如果我将节名设为null,则不返回任何内容

  3. 我不知道不想使用ReadAllText


这样的蛮力

解决方案

此处是作者说支持无节键的库。我本人还没有尝试过该库。

或者,您可以简单地编辑Ini文件,并在顶部添加一个标题 /节名称,然后在完成阅读后将其删除。 / p>

My ini file does not have any section. It has following data

com.ibm.rcp.toolbox.admin/toolboxvisibleChild=false
com.ibm.collaboration.realtime.community/defaultAuthType=ST-DOMINO-SSO
com.ibm.collaboration.realtime.brokerbridge/startBroker=false
com.ibm.collaboration.realtime.webapi/startWebContainer=true

I want to use function.

    [DllImport("kernel32")]
    private static extern int GetPrivateProfileString(string section,
             string key,string def, StringBuilder retVal,
        int size,string filePath);

My problems

  1. I cannot give section name in the function because I dont have any
  2. If I give section name null, it returns nothing
  3. I don't want to use brute force like ReadAllText

解决方案

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.

这篇关于读ini文件没有任何节吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆