Rob*_*cks 6 vb.net binaryfiles bytearray filestream
如何从任何文件中读取原始字节数组...
Dim bytes() as Byte
Run Code Online (Sandbox Code Playgroud)
..然后将该字节数组写回一个新文件?
我需要它作为一个字节数组来进行一些处理.
我目前正在使用:
阅读
Dim fInfo As New FileInfo(dataPath)
Dim numBytes As Long = fInfo.Length
Dim fsAs 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()
Run Code Online (Sandbox Code Playgroud)
来写
Dim fs As System.IO.FileStream
fs = New System.IO.FileStream(outpath, System.IO.FileMode.Create)
fs.Write(bytes, 0, bytes.Length)
fs.Close()
Run Code Online (Sandbox Code Playgroud)
Tom*_*ier 15
Dim data() as Byte = File.ReadAllBytes(path1)
File.WriteAllBytes(path2, data)
Run Code Online (Sandbox Code Playgroud)