# 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.
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

progCommented:
shurely shome mishtake

lngWhole = LOF(1) \ 10000

wouldn't it be
0
Author Commented:
thanks..
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.