'将文件以二进制流形式读入Byte数组
'=============================================
Public Function RetFile() As Byte()
Dim BA() As Byte
Dim FS As New IO.FileStream("C:\hello.doc", IO.FileMode.Open)
'Dim MS As New IO.MemoryStream
Dim FR As New IO.BinaryReader(FS)
BA = FR.ReadBytes(FS.Length)
FR.Close()
FS.Close()
Return BA
End Function
'将Byte数组写入文件
'=============================================
Private Sub SaveNewFile(ByVal ibuf() As Byte)
Dim FS As New IO.FileStream("C:\HelloEric.doc", IO.FileMode.CreateNew)
' Create the writer for data.
Dim w As New IO.BinaryWriter(FS)
' Write data to Test.data.
w.Write(ibuf)
w.Close()
FS.Close()
End Sub
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/EricBai/archive/2005/11/11/527257.aspx
评论