Re: [VB6 ] duplicate binary file
※ 引述《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
討論串 (同標題文章)
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章