var flag = false; var modified = false; var lines = File.ReadLines(fileName) .Where(line => { if ((!flag && line.Contains("#region " + regionName)) || (flag && line.Contains("#endregion"))) { flag = !flag; modified = true; return false; } return true; }) .ToArray(); if (modified) { File.WriteAllLines(fileName, lines); }
No comments:
Post a Comment