Binary Files Comparison
-
I m doing on a project which requires me to do a binary file comparison. Can anyone help? How do i go abt coding it?
Sounds like a homework project. We can't write the code for you. You'll have to start writing the code and then we can help with specific problems. RageInTheMachine9532
-
Sounds like a homework project. We can't write the code for you. You'll have to start writing the code and then we can help with specific problems. RageInTheMachine9532
Private Sub CompareBinaryFiles(t1 As String, t2 As String) Open txtOne.Text For Binary Access Read As #1 Open txtTwo.Text For Binary Access Read As #2 Dim pos As Long Dim differencepercentage As Single Dim o As Byte, t As Byte Dim textOne As String, textTwo As String Dim totalcount As Integer, differencecount As Integer 'need to initalize before computing totalcount = 0 differencecount = 0 On Error GoTo exit2 'loop the file until EOF Do Until EOF(2) 'count + 1 whenever the file loop totalcount = totalcount + 1 'calculating the positioning of the file pos = pos + 1 pos2 = pos2 + 1 If pos > txtOne Then GoTo exit2 Get #1, pos, t Get #2, pos, o 'add the countdiffernces by 1 If t <> o Then lstMistakes.AddItem "Byte " & pos & " - " & t & " (" & o & ")" If t <> o Then differencecount = differencecount + 1 'DoEvents If pos Mod 256 = 0 Then PB.Value = pos Loop GoTo esc exit2: If pos2 = cut Then GoTo esc lstMistakes.AddItem "---File ended at byte " & pos2 & " ---" esc: lstMistakes.Visible = True PB.Visible = False Close #1 Close #2 'calculating the percentage of the differnces of files On Error GoTo errhandler 'differencepercentage = (differencecount / totalcount) * 100 List2.AddItem "Binary Compare Similarity :" & 100 - differencepercentage & " %" List2.AddItem "Binary Compare diffences :" & differencepercentage & " %" Exit Sub errhandler: Resume Next End Sub Is this the way to do the binary files comparison? But when i include this function my normal text files comparison will have a extra line at the end of each documents!