因此,我有6个不同的文本文件,我想根据用户选择要比较的内容来相互比较。我的程序已经比较了文本文件,并给出了文本文件相同还是不同的输出。我现在想能够添加它的功能,说出它在哪些行号上不同,以及添加/删除了哪些字符。
我这样初始化了字符串数组:'''string [] texta''''''string [] textb''''''string [] textc'''等。
假设string []数组中已经有文本,就像我自己做的那样:'''texta = System.IO.File.ReadAllLines(@“ texta.txt”);'''
StreamReader obj1;
StreamReader obj2;
obj1 = new StreamReader(@"texta.txt");
obj2 = new StreamReader(@"textb.txt");
string Text1;
string Text2;
int line=0;
while (!obj1.EndOfStream || !obj2.EndOfStream)
{
Text1 = obj1.ReadLine();
Text2 = obj2.ReadLine();
if (Text1 != Text2)
{
break;
}
else
line++;
}
// line = line Nr. not the same