我该如何从任意文件中读取原始字节数组...
Dim bytes() as Byte
我需要将这个字节数组写回到一个新文件中吗?
我需要它作为一个字节数组,在其中进行一些处理。
我目前正在使用:
读取:
Dim fInfo As New FileInfo(dataPath)
Dim numBytes As Long = fInfo.Length
Dim fs As New FileStream(dataPath, FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(CInt(numBytes))
br.Close()
fs.Close()
编写代码
Dim fs As System.IO.FileStream
fs = New System.IO.FileStream(outpath, System.IO.FileMode.Create)
fs.Write(bytes, 0, bytes.Length)
fs.Close()