What's the easiest way to find out if two text files are different programmatically? Given two files I just need to know whether they are different or not. This is for a quick tool to help with a particularly nasty merge (switched languages from VB to C# in one branch (yay!) and made many changes in the other), it won't be going into production.
Possible solutions:
If possible ignoring white space would be awesome but I don't care that much about it. The main thing is this it needs to be quick and easy.
I'm using .Net 3.5sp1 by the way. Thanks for any ideas or pointers.
There is an article in the Microsoft Knowledge Base, hope it helps. They compare the bytes to see whether two files are different - How to create a File-Compare function in Visual C#
The fastest way to do that is comparing byte-to-byte of the files loaded on a stream. Hashing both files will take too long for large files, string compare too, external tools too.
Comparing byte-to-byte will be the best for you, as it will only reach the EOF of the files when both are identical.
If you do hash compare, string compare or external tools you'll have to go through the entire files all the times you compare, comparing byte-to-byte will do it only in case they're identical.
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