Results 1 to 7 of 7

Thread: Comparing Files

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    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 ?

  2. #2
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    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).

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    Thanks for your reply Crazy D.

    Where can I download Beyond Compare from ?

  4. #4
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    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.

  6. #6
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    hi
    something to start with...
    Code:
    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

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    Thanks again.

    nmretd.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width