We Recommend

Beginning VB.NET Beginning VB.NET
Visual Basic .NET is the latest version of the most widely used programming language in the world, popular with professional developers and complete beginners alike. This book will teach you Visual Basic .NET from first principles. You'll quickly and easily learn how to write Visual Basic .NET code and create attractive windows and forms for the users of your applications.


Posted By

lfbarbieri on 01/22/07


Tagged

conversion stream ByteArray


Versions (?)


Stream to Byte Array


Published in: VB.NET 


  1. Private Function GetStreamAsByteArray(ByVal stream As System.IO.Stream) As Byte()
  2.  
  3. Dim streamLength As Integer = Convert.ToInt32(stream.Length)
  4.  
  5. Dim fileData As Byte() = New Byte(streamLength) {}
  6.  
  7. ' Read the file into a byte array
  8. stream.Read(fileData, 0, streamLength)
  9. stream.Close()
  10.  
  11. Return fileData
  12.  
  13. End Function

Report this snippet 

You need to login to post a comment.