📜  在c#代码示例中删除文件中的特定行

📅  最后修改于: 2022-03-11 14:48:38.206000             🧑  作者: Mango

代码示例2
string line = null;
string line_to_delete = "the line i want to delete";

using (StreamReader reader = new StreamReader("C:\\input")) {
    using (StreamWriter writer = new StreamWriter("C:\\output")) {
        while ((line = reader.ReadLine()) != null) {
            if (String.Compare(line, line_to_delete) == 0)
                continue;

            writer.WriteLine(line);
        }
    }
}