public void DeleteIniSection(string filePath, string searchSectionText) { if (!File.Exists(filePath)) { return; } IniList.AddRange( MiscFunctions.GetSections(filePath) .Where(sectionName => !string.IsNullOrEmpty(sectionName)) .Where(sectionName => Regex.IsMatch(sectionName, searchSectionText)) .Select(sectionName => new IniInfo { FilePath = filePath, SectionName = sectionName })); }
public void DeleteIniValue(string filePath, string searchSectionText, string searchValueNameText) { if (!File.Exists(filePath)) { return; } foreach ( var sectionName in MiscFunctions.GetSections(filePath) .Where(sectionName => !string.IsNullOrEmpty(sectionName)) .Where(sectionName => Regex.IsMatch(sectionName, searchSectionText))) { IniList.AddRange(MiscFunctions.GetValues(filePath, sectionName) .Cast <KeyValuePair <string, string> >() .Where(kvp => Regex.IsMatch(kvp.Key, searchValueNameText)) .Select(kvp => new IniInfo { FilePath = filePath, SectionName = sectionName, ValueName = kvp.Key })); } }