Byte Array To String

Here is a very simple code snippet for converting a Byte Array to a String in VB.Net


And here is a function for that uses it to convert a byte array to a string

Private Function streamToString(ByVal stream As System.IO.MemoryStream) As String
Dim o As New IO.StreamWriter(stream, System.Text.Encoding.Default)
Dim bytes(stream.Length - 1) As Byte
stream.Read(bytes, 0, stream.Length - 1)
Return Encoding.ASCII.GetString(bytes)
End Function


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s