Cannot access a closed Stream of a memoryStream, how to reopen?

You can clone the original one and then use the clone, even when the original has been closed. Even though the original one is created with a capacity of 1000, ToArray() returns a 2 element array. ToBuffer() on the other hand gets you the entire buffer, which is what you don’t want.

MemoryStream original = new MemoryStream(1000);
original.WriteByte(4);
original.WriteByte(5);

MemoryStream dolly = new MemoryStream(original.ToArray());
dolly.Seek(0, SeekOrigin.Begin);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)