在 ini FILE VB.net 或 C# 中复制密钥



我正在尝试在 ini 文件中具有重复的键,如下所示:

[section]
key1 = "value1"
key2 = "value2"
key1 = "value....."
Private Declare Ansi Function WritePrivateProfileString _
  Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _
  (ByVal lpApplicationName As String, _
  ByVal lpKeyName As String, ByVal lpString As String, _
  ByVal lpFileName As String) As Integer

您可能希望将 ini 文件重复键读取到查找实例中。

如下所示的内容可能会有所帮助:

System.IO.StreamReader YourIniFile = new System.IO.StreamReader("yourIniFilePath");
string fileText = YourIniFile.ReadToEnd();  
string[] splitText = fileText.Split(new string[] {"n", "rn"}, StringSplitOptions.RemoveEmptyEntries);
ILookup<string, string> ini = splitText.ToLookup(key=> key.Substring(0, key.IndexOf("=")),
                               value => value.Substring(value.IndexOf("=")));

相关内容

  • 没有找到相关文章

最新更新