I need to compare 2 text files and save the differences in another file.
File 1
aaa
bbb
ccc
File 2
aaa
eee
ccc
ccc
I'm currently using this code:
String directory = @"C:\Users\confronto.txt";
String[] linesA = File.ReadAllLines(Path.Combine(directory, @"C:\Users\pari.txt"));
String[] linesB = File.ReadAllLines(Path.Combine(directory, @"C:\Users\dispari.txt"));
IEnumerable<String> onlyB = linesB.Except(linesA);
but this code doesn't see the double ccc
as a difference, so the confronto.txt
is:
eee
instead of:
eee
ccc
as it should be.
Can you help me? Thank you.