在,有两个文本文件的情况下:
FileA.txt
测试
1234
测试
FileB.txt
测试
5667
池塘
和所有出现FileA.txt将从FileB.txt被删除,被输出到FileC.txt
所以FileC.txt内容如下:
5667
池塘
解决方案
File.WriteAllLines(FileC.txt
。File.ReadAllLines(FileB.txt)除(File.ReadAllLines(FileA.txt)));
In the case that there were two text files:
FileA.txt
test
1234
testing
FileB.txt
test
5667
pond
and all occurrences in FileA.txt would be removed from FileB.txt, being output into FileC.txt
So FileC.txt would read:
5667
pond
解决方案
File.WriteAllLines("FileC.txt",
File.ReadAllLines("FileB.txt").Except(File.ReadAllLines("FileA.txt")));