VB.NET Programming Examples: Email, Encryption, Zip, HTTP, XML, FTP

Chilkat Software Components

Write Byte Array to File

Back

Demonstrates how to save a byte array to a file.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim fStream As New FileStream("byteArray.dat", FileMode.CreateNew)

        Dim bw As New BinaryWriter(fStream)

        Dim data(19) As Byte
        Dim i As Integer
        For i = 0 To 19
            data(i) = CByte(i)
        Next i
        bw.Write(data)

        bw.Close()

        fStream.Close()

    End Sub