首页 | 社区 | 博客 | 招聘 | 文章 | 新闻 | 下载 | 项目交易 | 网友作品 | 读书 | ACM题库 | 源码
亲,您未登录哦! 登录 | 注册

如何比较两个文件

(加入日期: 2002-03-10 )

打印文章】【字体:

分享到:
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

本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )

编程爱好者论坛

本栏最新文章