Come faccio a leggere un array di byte grezzo da qualsiasi file ...VB - Come faccio a leggere e scrivere un file binario?
Dim bytes() as Byte
..e poi scrivere che matrice di byte di nuovo in un nuovo file?
Ho bisogno di un array di byte per eseguire qualche elaborazione in mezzo.
Attualmente sto usando:
Per leggere
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()
Per scrivere
Dim fs As System.IO.FileStream
fs = New System.IO.FileStream(outpath, System.IO.FileMode.Create)
fs.Write(bytes, 0, bytes.Length)
fs.Close()
che ne pensi di pubblicare il tuo tentativo? –
Simile a http://stackoverflow.com/questions/1450542/c-how-do-i-read-and-write-a-binary-file ... ma diverso poiché C# può fare cose che VB.NET puo ' t. –
"C# può fare cose che VB.NET non può" - cura di nominarne alcuni, oltre ad alcuni aspetti della gestione XML? –