I have two large text files (about 1.8 GB each encoded in UTF-8). And I want to check if the content of both files are 100% same. If there is single character difference then it is considered not same, i.e. both files are different. How do I do that?
So my question is: How to check if 2 large text files content are 100% same?
Dim开发者_Python百科 TextFile1 as String = "C:\TextFile1.log"
Dim TextFile2 as String = "C:\TextFile2.log"
UPDATE:
I forgot to add, the solution should be using minimal memory because the specific PC only has 256 mb memory
Well, for starters you can compare their size (if they're not the same size they can't have the same content). Look at the FileInfo.Length property for this.
If they do have the same size, you can compare them byte by byte
I have run into a similar problem where I needed to identify duplicate pdf files that had the names changed. The best way to do this was by using md5 hash. I did a quick google search and it looks vb.net does have support built in funcationallity to do this. Check out http://www.vbknowledgebase.com/?Id=88&Desc=Find-Duplicate-files-using-Vb.Net-using-MD5-Hash
精彩评论