本文介绍了C#中 - 如何比较两个不同的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在,有两个文本文件的情况下:
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")));
这篇关于C#中 - 如何比较两个不同的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!