How to convert byte array to stream

Possible duplicate:
How to convert byte [] to stream in C #?

I need to convert an array of bytes to a stream. How to do it in C #?

This is an asp.net application.

FileUpload Control Name: taxformUpload

Program

byte[] buffer = new byte[(int)taxformUpload.FileContent.Length]; taxformUpload.FileContent.Read(buffer, 0, buffer.Length); Stream stream = ConvertToStream(buffer); 
+58
c #
Mar 29 '12 at 3:28
source share
3 answers

Simple, just wrap a MemoryStream around it:

 Stream stream = new MemoryStream(buffer); 
+147
Mar 29 '12 at 3:30
source share
— -

In your case:

 MemoryStream ms = new MemoryStream(buffer); 
+13
Mar 29 2018-12-12T00:
source share

I use what John Rush said:

 Stream streamContent = taxformUpload.FileContent; 
+1
Mar 29 '12 at 4:59
source share



All Articles