如何比较两个文件

王朝厨房·作者佚名  2007-01-04
宽屏版  字体: |||超大  

Function CompFile(F1 as string, F2 as string) as boolean

Dim issame as boolean

Open F1 For Binary As #1

Open F2 For Binary As #2

issame = True

If LOF(1) <> LOF(2) Then

issame = False

Else

whole& = LOF(1) \ 10000 注释:number of whole 10,000 byte chunks

part& = LOF(1) Mod 10000 注释:remaining bytes at end of file

buffer1$ = String$(10000, 0)

buffer2$ = String$(10000, 0)

start& = 1

For x& = 1 To whole& 注释:this for-next loop will get 10,000

Get #1, start&, buffer1$ 注释:byte chunks at a time.

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 the remaining bytes at the end

Get #2, start&, buffer2$ 注释:get the remaining bytes at the end

If buffer1$ <> buffer2$ Then

issame = False

End If

Close

CompFile = issame

End Function

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有