Re: CryptoStream.Dispose closes target stream in 2.0
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Wed, 23 Nov 2005 17:49:04 -0000
Harold Howe <hhowe@xxxxxxxxxxxx> wrote:
> > In this case, however, your code can be improved in simplicity and will
> > still work in both cases:
>
> <snip>
>
> Thanks. It looks like the main addition in your code is this:
>
> data = msout.ToArray();
>
> So it is safe to use ToArray after the memory stream is closed? The
> entire concept of closing a memory stream is somewhat fuzzy to me.
Yes, ToArray is fine after closing the stream. From the docs:
<quote>
Note
This method works when the MemoryStream is closed.
</quote>
> > If you're dealing with other streams, you could use my
> > NonClosingStreamWrapper, available from
> > http://www.pobox.com/~skeet/csharp/miscutils
>
> Cool. Thanks.
>
> The correct link is http://www.pobox.com/~skeet/csharp/miscutil for
> anyone reading the archive of this.
Whoops - sorry!
> > CryptoStream.Dispose was broken in 1.1 in that it didn't close the
> > CryptoStream itself - IIRC it was actually a no-op.
>
> .net reflector showed that it wasn't quite a no-op, but it doesn't do a
> close or flush either.
The point I noticed when I looked before is that it doesn't flush the
final block (which is part of Close, IIRC).
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- References:
- CryptoStream.Dispose closes target stream in 2.0
- From: Harold Howe
- Re: CryptoStream.Dispose closes target stream in 2.0
- From: Jon Skeet [C# MVP]
- Re: CryptoStream.Dispose closes target stream in 2.0
- From: Harold Howe
- CryptoStream.Dispose closes target stream in 2.0
- Prev by Date: Re: CryptoStream.Dispose closes target stream in 2.0
- Next by Date: Re: MSIL size limit
- Previous by thread: Re: CryptoStream.Dispose closes target stream in 2.0
- Next by thread: Re: debugger runs to end of function
- Index(es):
Relevant Pages
|