6

任意のファイルから生のバイト配列を読み取るにはどうすればよいですか...

 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()
4

3 に答える 3

16
Dim data() as Byte = File.ReadAllBytes(path1)
File.WriteAllBytes(path2, data)
于 2009-09-20T08:11:49.527 に答える
5
System.IO.File.ReadAllBytes("myfile.txt")
于 2009-09-20T08:11:24.770 に答える
3

これを試して:-

Dim bytes() as Byte
bytes = File.ReadAllBytes(fileName)
'' # Do stuff to the array
File.WriteAllBytes(otherFileName, bytes)
于 2009-09-20T08:12:17.647 に答える