Skip to Entry #3 for a more efficient way (thank you Erel)
____
Edit:Code to compare two files: One slow way to compare two files:
____
Edit:
B4X:
Sub FilesAreIdentical(strFile1 As String, strFile2 As String) As Boolean
If File.Size("", strFile1) <> File.Size("", strFile2) Then Return False
Dim in1 As InputStream
Dim in2 As InputStream
in1 = File.OpenInput("", strFile1)
in2 = File.OpenInput("", strFile2)
Dim buffer1(File.Size("", strFile1)) As Byte
Dim buffer2(File.Size("", strFile2)) As Byte
in1.ReadBytes(buffer1, 0, buffer1.length)
in2.ReadBytes(buffer2, 0, buffer2.length)
Dim data1(buffer1.Length) As Byte
Dim data2(buffer2.Length) As Byte
Dim md As MessageDigest
data1 = md.GetMessageDigest(buffer1, "MD5")
data2 = md.GetMessageDigest(buffer2, "MD5")
Dim Bconv As ByteConverter
Return ( Bconv.HexFromBytes(data1) = Bconv.HexFromBytes(data2) )
End Sub
Last edited: