Monday, 15 February 2016

Difference Between Memory Stream and file Stream.

Serialization is a process of converting object into byte streams for storing Data in any Backing Device.
During the Serialization we can use either file stream or Memory stream.
Memory Stream is representation of data in byte stream format in memory because there is no any backing store for Byte stream . Memory Stream reduce the need for temporary buffers and files in an application. where as File stream is used for read data from disk or file .
a memory stream can be used to read data that is  mapped in the computer's internal memory (RAM). You are basically reading/writing streams of bytes from memory.
There are two ways to create a MemoryStream.
You can initialize one  from an unsigned byte array or we can create an empty one. Empty memory streams are resizable.
Advantage of a memory stream is that there is no need to create temporary bufers and files in an application.
File stream and memory stream both are classes in C# and it derives from System.IO namespace.

No comments:

Post a Comment