Dim a Dim c() As Byte Dim sd As ADODB.Stream Set sd = New ADODB.Stream sd.loadfromfile filename a = sd.Read c = a
Dim c() As Byte Dim sd As ADODB.Stream Set sd = New ADODB.Stream sd.write c sd.savefile filename
谢谢楼上的,但是我需要API完成,不是使用ADO组件
用Api的话:OpenFile,ReadFile 实际Vb就行呀! dim bytAry() as byte dim lngL as long filhandle = FreeFile() lngL = filelen(filename) Open filename for binary as #filehandle redim bytAry(0 to lngl -1 ) input #filehandle,,bytAry close #filehandle
Private Sub Command1_Click() Dim n As Long Dim arrBytes() As Byte
Open "c:\windows\1stboot.bmp" For Binary As 1 '转换 n = LOF(1) ReDim arrBytes(1 To n) As Byte Get 1, , arrBytes Close 1 Open "c:\temp.bmp" For Binary As 1 '逆转换 Put 1, , arrBytes Close 1 MsgBox " ok!"
Dim c() As Byte
Dim sd As ADODB.Stream
Set sd = New ADODB.Stream
sd.loadfromfile filename
a = sd.Read
c = a
Dim sd As ADODB.Stream
Set sd = New ADODB.Stream
sd.write c
sd.savefile filename
实际Vb就行呀!
dim bytAry() as byte
dim lngL as long
filhandle = FreeFile()
lngL = filelen(filename)
Open filename for binary as #filehandle
redim bytAry(0 to lngl -1 )
input #filehandle,,bytAry
close #filehandle
Dim n As Long
Dim arrBytes() As Byte
Open "c:\windows\1stboot.bmp" For Binary As 1 '转换
n = LOF(1)
ReDim arrBytes(1 To n) As Byte
Get 1, , arrBytes
Close 1
Open "c:\temp.bmp" For Binary As 1 '逆转换
Put 1, , arrBytes
Close 1
MsgBox " ok!"
End Sub
[email protected]