参考自:http://zhidao.baidu.com/question/87467507.html
//定义一个变量用来存读到的东西
string text = "";
//用一个读出流去读里面的数据
using (StreamReader reader = new StreamReader(@"C:\db.txt", Encoding.GetEncoding("gb2312")))
{
//读一行
string line = reader.ReadLine();
while (line != null)
{
//如果这一行里面有abe这三个字符,就不加入到text中,如果没有就加入
if (line.IndexOf("abc") >= 0)
{
}
else
{
text += line + "\r\n";
}
//一行一行读
line = reader.ReadLine();
}
}
//定义一个写入流,将值写入到里面去
using (StreamWriter writer = new StreamWriter(@"C:\db.txt"))
{
writer.Write(text);
}