find Count of open Streams?

  • Thread starter Thread starter viepia
  • Start date Start date
V

viepia

Hi,

In the function

void close(BinaryReader br)
{
br.BaseStream.Close(); // Is this line necessary?
br.Close();
}

Is there a I/O function to find the number of open Stream(s) analogous to
LogStore.StreamCount?

Thanks,
Viepia
 
Is this line necessary?

No; BinaryReader assumes ownership of the stream, and calling Close()/
Dispose() on the BinaryReader also calls Close() on the base-stream.
Sometimes this can be rritating ;-p Some other readers offer a flag in
the constructor to specify "should I also close the base reader?" -
but not this one.

You might, however, wish to consider "using" either of the stream/
reader; this would ensure that Dispose() is called regardless of
whether your method exist cleanly or via an exception.
Is there a I/O function to find the number of open Stream(s) analogous to
LogStore.StreamCount?

I don't think so.
 
Thanks!
Viepia
No; BinaryReader assumes ownership of the stream, and calling Close()/
Dispose() on the BinaryReader also calls Close() on the base-stream.
Sometimes this can be rritating ;-p Some other readers offer a flag in
the constructor to specify "should I also close the base reader?" -
but not this one.

You might, however, wish to consider "using" either of the stream/
reader; this would ensure that Dispose() is called regardless of
whether your method exist cleanly or via an exception.


I don't think so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top