Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you know if a stream is closed? [closed]

Tags:

c#

.net

stream

I have a method with a Stream for input :

public void Export(Stream finalOutPutStream)

For test purposes, i call it with a memory stream, like this :

// When
_exporter.Export(new System.IO.MemoryStream());

But when, in the method, i want to write on this memory stream, i get a ObjectDisposedException.

This stream is not enclosed in a using statement, i do not call explicitely .Dispose().

What happened ?

Thanks :)

-- EDIT : my bad, the problem is from the third party writer (DotNetZip). The exception happens when i call zip.Save(new MemoryStream()). I will ask my questions on their forum. Sorry, and thanks for the help.

like image 629
Maxime ARNSTAMM Avatar asked Aug 29 '11 09:08

Maxime ARNSTAMM


1 Answers

You can check stream availability using: CanRead, CanSeek, CanWrite properties.

like image 81
Kirill Polishchuk Avatar answered Oct 08 '22 00:10

Kirill Polishchuk