How do I convert struct System.Byte byte[] to a System.IO.Stream object in C#?

Mehdi Hadeli picture Mehdi Hadeli · Jan 19, 2011 · Viewed 587.6k times · Source

How do I convert struct System.Byte byte[] to a System.IO.Stream object in C#?

Answer

Martin Buberl picture Martin Buberl · Jan 22, 2011

The easiest way to convert a byte array to a stream is using the MemoryStream class:

Stream stream = new MemoryStream(byteArray);