I am looking for the best way to compare 2 text files (+-15000lines) quickly and get as output strings that are differents in the two files. 1st one is an old inventory, new one is the current inventory and I would like to generate an third one containing strings that are different between file2 & file1. (95% of the 2 files will be similar).
Very simple approach, assuming that similar means equal:
var file1Lines = File.ReadLines(file1Path);
var file2Lines = File.ReadLines(file2Path);
IEnumerable<String> inFirstNotInSecond = file1Lines.Except(file2Lines);
IEnumerable<String> inSecondNotInFirst = file2Lines.Except(file1Lines);
You can use foreach
to enumerate the lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With