• Status: Solved
• Priority: Medium
• Security: Public
• Views: 128

# How to determin if 2 files are exactly the same?

Please show me the code to test weather 2 files are identical. The date/time stamp would be ok I guess.
Please be specific when offering the code sample.
Thanks.
0
a6106a
1 Solution

Commented:
' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 14/06/99
' * Time             : 11:53
' **********************************************************************
' * Comments         : Compares the content of two files
' *
' *
' **********************************************************************

Sub CompareFiles(strPath1 As String, strPath2 As String)
Dim blnSame As Boolean
Dim lngWhole As Long
Dim lngPart As Long
Dim strBuffer1 As String
Dim strBuffer2 As String
Dim lngStart As Long
Dim intCount As Integer
Open strPath1 For Binary As #1
Open strPath2 For Binary As #2
blnSame = True
If LOF(1) <> LOF(2) Then
blnSame = False
Else
lngWhole = LOF(1) 10000 'number of whole 10,000 byte chunks
lngPart = LOF(1) Mod 10000 'remaining bytes at end of file
strBuffer1 = String\$(10000, 0)
strBuffer2 = String\$(10000, 0)
lngStart = 1
For intCount = 1 To lngWhole 'this for-next loop will get 10,000
Get #1, lngStart, strBuffer1 'byte chunks at a time.
Get #2, lngStart, strBuffer2
If strBuffer1 <> strBuffer2 Then
blnSame = False
Exit For
End If
lngStart = lngStart + 10000
Next
strBuffer1 = String\$(lngPart, 0)
strBuffer2 = String\$(lngPart, 0)
Get #1, lngStart, strBuffer1 'get the remaining bytes at the end
Get #2, lngStart, strBuffer2 'get the remaining bytes at the end
If strBuffer1 <> strBuffer2 Then blnSame = False
End If
Close
If blnSame Then
MsgBox "Files are identical", 64, "Info"
Else
MsgBox "Files are NOT identical", 16, "Info"
End If
End Sub

0

Commented:
shurely shome mishtake

lngWhole = LOF(1) \ 10000

wouldn't it be
0

Author Commented:
thanks..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.