I've tried rewriting this code several times, it spits out the bytes correctly, but then when trying to read the array created from the memory stream, it's empty, what am I doing wrong?
Dim bytes() As Byte = System.Text.Encoding.ASCII.GetBytes("test this shit")
Dim bytesString As String = ""
Dim i As Integer = 0
i = 0
Dim byteStream As New System.IO.MemoryStream
Do While i < bytes.Length
If bytes(i).ToString <> 0 Then
bytesString = bytesString & "|" & bytes(i).ToString
byteStream.WriteByte(bytes(i))
Debug.Print(bytes(i).ToString)
End If
i = i + 1
Loop
i = 0
byteStream.Flush()
Dim newBytes(byteStream.Length - 1) As Byte
byteStream.Read(newBytes, 0, byteStream.Length)
byteStream.Close()
Dim stringData As String = System.Text.Encoding.ASCII.GetString(newBytes)
Debug.Print("Data: " & stringData)