21
Февраль
2009
Как сравнить 2 файла на идентичность?
Как сравнить 2 файла на идентичность?
Option Explicit Private Sub Command1_Click() Dim issame As Boolean Dim whole As Long Dim part As Long Dim buffer1 As String Dim buffer2 As String Dim start As String Dim X As Long Open App.Path & "\1.txt" For Binary As #1 Open App.Path & "\2.txt" For Binary As #2 issame = True If LOF(1) <> LOF(2) Then issame = False Else whole = LOF(1) \ 10000 part = LOF(1) Mod 10000 buffer1 = String$(10000, 0) buffer2 = String$(10000, 0) start = 1 For X = 1 To whole Get #1, start, buffer1 Get #2, start, buffer2 If buffer1 <> buffer2 Then issame = False Exit For End If start = start + 10000 Next buffer1 = String$(part, 0) buffer2 = String$(part, 0) Get #1, start, buffer1 Get #2, start, buffer2 If buffer1 <> buffer2 Then issame = False End If Close #1 Close #2 If issame Then MsgBox "Файлы идентичны", 64, "Info" Else MsgBox "Файлы Не идентичны", 16, "Info" End If End Sub