title: Is there a method to determine if a System.IO.StreamWriter object is open?
body: <p>Im trying to determine if a <code>StreamWriter</code> object is open or already closed in a script.  If it's not closed, I can write a new line to the file.  If it is closed, I need to perform other actions....</p>
  
  <p>How can I verify if a stream is still open?</p>
  
  <p>Example test script.</p>
  
  <pre><code>$stream = [System.IO.StreamWriter] "C:\testing.txt"
  $stream.WriteLine("TEST")
  $stream.close()
  if($stream)){
      #stream still open, write new line
      $stream.WriteLine("Stream is still open.  Write.")
      $stream.close()
  }else(
      #stream not open... end script, send reponse.
  }
  </code></pre>