How to clear MemoryStream ?
-
Greetings Comrades, Does anybody knows how to clear Stream?
Stream memoryStream = new MemoryStream();
...
memoryStream.Flush() - does nothing
memoryStream.SetLength(0) - calls AccessViolationException ("memory is corrupt")Any help will be just fine. Thanks!!!
One nation - underground
-
Greetings Comrades, Does anybody knows how to clear Stream?
Stream memoryStream = new MemoryStream();
...
memoryStream.Flush() - does nothing
memoryStream.SetLength(0) - calls AccessViolationException ("memory is corrupt")Any help will be just fine. Thanks!!!
One nation - underground
you close and dispose it.
-
Greetings Comrades, Does anybody knows how to clear Stream?
Stream memoryStream = new MemoryStream();
...
memoryStream.Flush() - does nothing
memoryStream.SetLength(0) - calls AccessViolationException ("memory is corrupt")Any help will be just fine. Thanks!!!
One nation - underground
Did you use this :
memoryStream.Dispose();
-
Did you use this :
memoryStream.Dispose();
-
Nope. The only way to clear it out is to Seek to position 0 and write 0's to every known position. Depending on the size of the Stream, it's porobably going to be faster, or at least easier, to just kill the existing stream and create a new one.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Nope. The only way to clear it out is to Seek to position 0 and write 0's to every known position. Depending on the size of the Stream, it's porobably going to be faster, or at least easier, to just kill the existing stream and create a new one.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Try this out
MemoryStream ms = new MemoryStream();
.......
......ms.SetLength(0);
ms.Position = 0;Hope this Works!!! :)