I can't convert byte to stream. Is there an easy way to do that?
Stream stream;
stream = (Stream) vByte; //something is going wrong in this part.
//vByte is a byte variable
There are two ways to convert byte array to String: By using String class constructor. By using UTF-8 encoding.
Deserializing (converting byte array into Object)
Streams are commonly written to byte arrays. The byte array is the preferred way to reference binary data in . NET. It can be used to data like the contents of a file or the pixels that make up the bitmap for an image.
First create FileStream to open a file for reading. Then call FileStream. Read in a loop until the whole file is read. Finally close the stream.
You need to instantiate a MemoryStream
object with the byte[]
:
MemoryStream stream = new MemoryStream(vByte);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With