I have been doing some research on this class and it says that it saves everything in memory... but in what memory? I think it's RAM, but I read on and it says temporary buffering etc. I would like you to help me with that theoretical doubt,
I have been doing some research on this class and it says that it saves everything in memory... but in what memory? I think it's RAM, but I read on and it says temporary buffering etc. I would like you to help me with that theoretical doubt,
The MemoryStream class creates a data stream that uses RAM as backup storage instead of the hard drive or network. The class
MemoryStream
encapsulates the stored information as an array (array
) of unsigned bytes that is initialized after object creationMemoryStream
, or thearray
can also be created empty. The encapsulated information is accessed directly in RAM memory. Memory streams (MemoryStream
) can reduce the need for the use ofBuffers temporales
and files in an application.Hello, I leave you this information, I hope it helps you:
The stream should actually be deleted even if there is an exception (most likely on file I/O) - so to write your memorystream , you can use:
And to read it again:
If the files are large, then it is worth noting that the read operation will use twice as much memory as the total size of the file. One solution to this is to create memorystream from the byte array - the code below assumes not, then write to that stream.
Greetings.