Click to See Complete Forum and Search --> : Comparing Files
nmretd
Nov 29th, 1999, 04:34 PM
I want to run a file compare for 2 separate directories and see what differences there are between the files that are compared.
How can I achieve this in VB ?
Crazy D
Nov 29th, 1999, 04:49 PM
Use Beyond Compare.. it's the best compare tool I've seen around.
If you want to do it yourself in VB, figure out how you want to disaplay the differences.
The idea is easy.. files that are not exacly the same size can never be the same.. then the ones that do have the same size, open them and ready byte for byte and compare them, as soon as they're not equeal, you have 2 different files...
to display what the differences are depends I think on how you want to display it to a user. I'd recommend to download beyond compare (since windiff sucks hard) and see how they show it (then you also know why it's the best tool around).
nmretd
Nov 29th, 1999, 05:07 PM
Thanks for your reply Crazy D.
Where can I download Beyond Compare from ?
Crazy D
Nov 29th, 1999, 05:24 PM
Good point... :-) http://www.scootersoftware.com/
nmretd
Nov 29th, 1999, 07:44 PM
Beyond Compare is great Crazy D. But just out of interest what function would I use to run a simple file compare in VB. Can you give me a quick example.
thanks.
Crazy D
Nov 29th, 1999, 08:20 PM
hi
something to start with...
Dim lFilePos As Long
Dim b1 As Byte, b2 As Byte
Dim bDifferent As Boolean
bDifferent = False
lFilePos = 1
Open "File1.ext" For Binary Access Read As #1 Len = Len(b1)
Open "File2.ext" For Binary Access Read As #2 Len = Len(b1)
Do Until EOF(1) Or EOF(2)
Get #1, , b1
Get #2, , b2
lFilePos = lFilePos + 1
If b1 <> b2 Then
bDifferent = True
Exit Do
End If
Loop
Close #1
Close #2
If bDifferent Then
MsgBox "NOt the same"
Else
MsgBox "the same"
End If
it works, just tested it.. quick though so watch out for errors....
hth
nmretd
Nov 29th, 1999, 08:46 PM
Thanks again.
nmretd.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.