作者fumizuki (小狮子)
看板Visual_Basic
标题Re: [VB6 ] duplicate binary file
时间Fri Aug 5 12:32:24 2005
※ 引述《acosy (acosy)》之铭言:
: 一个简单的二进位档复制..
: ------
: open "c:\xxx.1" for binary access read as #1
: open "c:\xxx.2" for binary access write as #2
: do until eof(1)
: get #1, ,a
: put #2, ,a
: loop
: close #1
: close #2
: --------
: 结果 xxx.2 总会比 xxx.1 多出 1 bytes, why??
多出一个 chr(0) ,不知道为何读到 0 ... eof才会是true @@
下面两种方法就不会有这问题
1)
Dim a As Byte
Open "c:\xxx.1" For Binary As #1
Open "c:\xxx.2" For Binary As #2
Do While Loc(1) < LOF(1)
Get #1, , a
Put #2, , a
Loop
Close
2)
Dim a() As Byte
Open "c:\xxx.1" For Binary As #1
Open "c:\xxx.2" For Binary As #2
Redim a(LOF(1) - 1)
Get #1, , a
Put #2, , a
Close
--
VB 程式设计 仓木麻衣 PTT 星爷板 行列输入法
======================================================
Visual_Basic MaiKuraki Stephen Array
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 210.58.156.43