我有一个文本文件 1,我希望在新文件 3 中提取行(文件 2 中不存在)
例子 :
文件1:
/**
* Gets the total volume.
*
* @return the total volume
*/
public int getTotalVolume() {return totalVolume;}
文件2:
* Gets the total volume.
*
* @return the total volume
文件3:
/**
*/
public int getTotalVolume() {return totalVolume;}
我的功能:
public void Traitv2(string file1, string file2, string file3)
{
StreamReader monStreamReaderfile1 = new StreamReader(file1);
StreamWriter monStreamWriterfile3 = new StreamWriter(file3);
string ligne = monStreamReaderfile1.ReadLine();
while (ligne != null)
{
StreamReader monStreamReaderfile2 = new StreamReader(file2);
string ligne1 = monStreamReaderfile2.ReadLine();
while (ligne1 != null)
{
if (!ligne.Equals(ligne1))
{
Console.WriteLine(ligne);
monStreamWriterfile3.WriteLine(ligne);
}
ligne1 = monStreamReaderfile2.ReadLine();
ligne = monStreamReaderfile1.ReadLine();
}
ligne = monStreamReaderfile1.ReadLine();
monStreamReaderfile2.Close();
}
monStreamWriterfile3.Close();
monStreamReaderfile1.Close();
}
当我运行此函数时,结果为 false 并出现错误:错误 Object reference not set to an instance of an object