private sub CopyFileEx(byavl SourceFile as string,byval DestFile as string) const BlockSize as long = &H100000& '一次复制1M,大小自己调整试试 dim bBuff() as byte,pFile as long redim bbuff(blocksize-1) '分配固定缓冲区 pfile=1 open sourcefile for binary as #1 open destfile for binary as #2 do if pfile+blocksize>lof(1) then '如果不够指定大小的块了,则是结束 redim bbuff(lof(1)-pfile) '剩下的长度计算 get #1,,bbuff() put #2,,bbuff() me.caption="100%" exit do end if get #1,,bbuff() put #2,,bbuff() pfile=pfile+blocksize me.caption=format(pfile/lof(1),"0.00") & "%" '报告进度 doevents loop close end sub 这样就差不多了
VB也只是略懂皮毛
在VB上纯用API来写我也是看得懂的
我喜欢用汇编调用API来写
我觉得这样很有趣
昨天百度了一下
WriteFile发现第四个参数是写入了多少
等我测试完了就结贴^-^
也麻烦给个实例这样我掌握的更快
const BlockSize as long = &H100000& '一次复制1M,大小自己调整试试
dim bBuff() as byte,pFile as long redim bbuff(blocksize-1) '分配固定缓冲区
pfile=1 open sourcefile for binary as #1
open destfile for binary as #2 do
if pfile+blocksize>lof(1) then '如果不够指定大小的块了,则是结束
redim bbuff(lof(1)-pfile) '剩下的长度计算 get #1,,bbuff()
put #2,,bbuff()
me.caption="100%"
exit do
end if
get #1,,bbuff()
put #2,,bbuff() pfile=pfile+blocksize
me.caption=format(pfile/lof(1),"0.00") & "%" '报告进度
doevents
loop close
end sub
这样就差不多了