Store Stream in cache

.NET Programming

A Stream is a pipe, not a bucket. If you need to store it, you must first get the actual contents. For example, you could read it all into a byte-array. For example:

Dim contents as Byte()

Using ms as new MemoryStream
    contents =  ms.ToArray()
End Using

You can store the byte-array trivially. Then if you want a Stream later, you can use new MemoryStream(contents).

Notes using this