Link to home
Start Free TrialLog in
Avatar of Howard Bash
Howard BashFlag for United States of America

asked on

Using System.IO.StreamWriter

How can I determine the state of a stream writer object?  I would like to know if it is open so that I can close it in my try catch finally block.  
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Howard Bash

ASKER

So, in a nutshell there is not status property or method and the way to "close" the stream is to dispose of it if it has been instantiated?
I have not seen any status property. Disposing it would close it as well.
Yes. In the case of a finally block, as you've described, there is no need to know the status.
Doh! I gotta learn to type quicker. ;)
If your intention is to close it then tgerbert ways is the best choice.