Home » c# » How to convert a byte array to Stream [duplicate]

How to convert a byte array to Stream [duplicate]

Posted by: admin November 29, 2017 Leave a comment

Questions:

Possible Duplicate:
How do I convert byte[] to stream in C#?

I need to convert a byte array to a Stream . How to do so in C#?

It is in 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);
Answers:

Easy, simply wrap a MemoryStream around it:

Stream stream = new MemoryStream(buffer);

Questions:
Answers:

In your case:

MemoryStream ms = new MemoryStream(buffer);

Questions:
Answers:

I am using as what John Rasch said:

Stream streamContent = taxformUpload.FileContent;