Results 1 to 5 of 5

Thread: compare text files

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    London Occupation: Desktop Developer
    Posts
    141

    compare text files

    Has anyone written something that can compare two text files and output the differences, or know of freewhere I can download to do this?

  2. #2
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Here is some code to work with:

    VB Code:
    1. Function SameFile(ByVal Path1$, ByVal Path2$) As Boolean
    2. 'Nucleus
    3.  Dim ba1() As Byte, ba2() As Byte
    4.  Dim ff&, i&, u&
    5.  
    6.  On Error Resume Next
    7.  If Len(Dir$(Path1)) And Len(Dir$(Path2)) Then
    8.     ff = FreeFile
    9.     Open Path1 For Binary As #ff
    10.     ReDim ba1(0 To LOF(ff) - 1)
    11.     Get #ff, , ba1
    12.     Close #ff
    13.  
    14.     ff = FreeFile
    15.     Open Path2 For Binary As #ff
    16.     ReDim ba2(0 To LOF(ff) - 1)
    17.     Get #ff, , ba2
    18.     Close #ff
    19.  
    20.     u = UBound(ba1)
    21.     If u = UBound(ba2) Then
    22.         For i = 0 To UBound(ba1)
    23.             If ba1(i) <> ba2(i) Then Exit For
    24.         Next
    25.         If i = u + 1 Then SameFile = True
    26.     End If
    27.  End If
    28. End Function

  3. #3
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    There is actually a DOS command that does this (at least there used to be). Can't remember the name of it though.

  4. #4
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    DOS file compare command (still works)

    fc filname1 filename2

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    London Occupation: Desktop Developer
    Posts
    141

    richyrich

    Thanks Nuke, found the dos command it is call ed comp

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