Bob Rock <no***************************@hotmail.com> wrote:
I've noticed that after calling the Close method on a StreamWriter, I get
exceptions on any operation I might request on the associated stream (with a
message "Cannot access a closed Stream"). Is this the behaviour I must
expect? Nothing is said on the documentation.
Yes, it's expected behaviour - but I agree it should be more clearly
documented. The StreamWriter is basically a wrapper, and when you close
the wrapper, it closes the wrapped stream as well. The same goes for
Dispose.
It is *sort* of documented - it says that Close is the same as
Dispose(true) and that "This [Dispose] method invokes the Dispose
method of each referenced object."
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too