using System.IO; namespace Housing.Services; public static class IniFile { public static Dictionary LoadSection(string filePath, string sectionName) { var values = new Dictionary(StringComparer.OrdinalIgnoreCase); var isTargetSection = false; foreach (var rawLine in File.ReadAllLines(filePath)) { var line = rawLine.Trim(); if (string.IsNullOrWhiteSpace(line) || line.StartsWith(';') || line.StartsWith('#')) { continue; } if (line.StartsWith('[') && line.EndsWith(']')) { var currentSection = line.Substring(1, line.Length - 2).Trim(); isTargetSection = string.Equals(currentSection, sectionName, StringComparison.OrdinalIgnoreCase); continue; } if (!isTargetSection) { continue; } var separatorIndex = line.IndexOf('='); if (separatorIndex <= 0) { continue; } var key = line.Substring(0, separatorIndex).Trim(); var value = line.Substring(separatorIndex + 1).Trim(); values[key] = value; } return values; } }