基本上我需要做的是這樣:比較2個文本文件和出口沒有在一號文件中存在線
File no.1:
1
2
4
5
51
21
File no.2:
31
21
4
What should be exported:
1
2
5
51
基本上只出口不中,第二存在線文本。
我當前的嘗試:
bool exists = false;
string[] lines1 = File.ReadAllLines("path1");
string[] lines2 = File.ReadAllLines("path2");
for (int i = 0; i < lines1.Length; i++)
{
for (int g = 0; g < lines2.Length; g++)
{
if (lines1[i] == lines2[g])
{
exists = true;
Console.WriteLine("Exists!");
break;
}
}
if (!exists)
{
Console.WriteLine(lines1[i]);
exists = false;
}
}
Console.WriteLine("End of file reached");
Console.ReadLine();
感覺好像是我用一個適當的功能,雖然這是我想出了,感謝您的幫助!
你確定你不是也想5中結果? –
@FrancescoB。哈哈!你是對的,那是我的不好:) – TricksterJoe