to ffb:
sorry,上次答得太仓促,inputB函数是用来在ascii码文件里读取二进制类型,
subzero的方法是对的,
他只说了读取二进制文件的方法,用
dim array() as byte
dim filehandle as integer
filehandle =freefile
open "c:\myexample.xxx" for binary access read as #filehandle
redim array(lof(filehandle)
get #filehandle,,array
同样,写入二进制文件的方法就是put #filesave,,array
dim filesave as integer
open "c:\mydestiny.xxx" for binary access write as #filesave
put #filesave,,array
subzero的方法是一次性读完,如果文件比较大的话,或者你想用winsock将所需要的字节发送出去的话,则需要限定数组的大小,多次读完,例如,由于winsock一次只能发送8k左右的字节数,因此.得做如下处理
dim array() as byte
dim filehandle as integer
dim mylocation as long
filehandle =freefile
open "c:\myexample.xxx" for binary access read as #filehandle
mylocation=loc(filehandle)
do while(1)
if lof(filehandle)-mylocation>4000 '这里一次读取4001字节
redim array(0 to 4000)
get #filehandle,,array
winsock.senddata array '发送出去
mylocation=loc(filehandle)
else
redim array(o to lof(filehandle)-mylocation-1)
get #filehandle,,array
winsock.senddata array '发送出去
exit do
end if
loop
dim array() as byte
dim filenum as long
filenum=freefile
open destfile for binary as #filenum
redim array(lof(filenum))
get #filenum,,array
close #filenum
现在读到array数组里了