public void RemoveTextLines(IList<string> linesToRemove) { // Read file using (StreamReader sr = new StreamReader("a.txt")) { // Write new file using (StreamWriter sw = new StreamWriter("b.txt")) { // Read lines string line; while ((line = sr.ReadLine()) != null) { // Look for text to remove if (!this.ContainsString(line, linesToRemove)) { // Keep lines that does not match sw.WriteLine(line); } } } } } private bool ContainsString(string line, IList<string> linesToRemove) { foreach (string s in linesToRemove) if (line.StartsWith(s)) return true; return false; }
asrety sgfrhjk etryuyy cvbjkj d epokgth berty rtyu
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question