WEB开发网
开发学院软件开发VB 比较两个文件 阅读

比较两个文件

 2006-02-27 21:08:29 来源:WEB开发网   
核心提示:FunctionCompFile(F1asstring,F2asstring)asbooleanDimissameasbooleanOpenF1ForBinaryAs#1OpenF2ForBinaryAs#2issame=TrueIfLOF(1)<>LOF(2)Thenissame=FalseElsewho
FunctionCompFile(F1asstring,F2asstring)asboolean
Dimissameasboolean
OpenF1ForBinaryAs#1
OpenF2ForBinaryAs#2

issame=True
IfLOF(1)<>LOF(2)Then
issame=False
Else
whole&=LOF(1)\10000'numberofwhole10,000bytechunks
part&=LOF(1)Mod10000'remainingbytesatendoffile
buffer1$=String$(10000,0)
buffer2$=String$(10000,0)
start&=1
Forx&=1Towhole&'thisfor-nextloopwillget10,000
Get#1,start&,buffer1$'bytechunksatatime.
Get#2,start&,buffer2$
Ifbuffer1$<>buffer2$Then
issame=False
ExitFor
EndIf
start&=start& 10000
Next
buffer1$=String$(part&,0)
buffer2$=String$(part&,0)
Get#1,start&,buffer1$'gettheremainingbytesattheend
Get#2,start&,buffer2$'gettheremainingbytesattheend
Ifbuffer1$<>buffer2$Then
issame=False
EndIf
Close
CompFile=issame
EndFunction->

Tags:比较 两个 文件

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接