title: TextWriter data missing but not throw exception
body: <p>I have some codes process data like:</p>
  <ol>
  <li>select data from database</li>
  <li>write data to TXT file</li>
  <li>update data flag in database</li>
  </ol>
  <p>In little accident case, the data only write partly to the file, but data flag had been updated. My console application will send an email if it catches an exception. But I don't receive the email, so I suppose there is no exception been caught.</p>
  <p>I have read some posts and documents about <code>StreamWriter</code>, and know the good practice when I try to fix this old application which I managed. But I'm curious if there are some possible reasons will affect I/O write or the error exception missing.</p>
  <pre class="lang-cs prettyprint-override"><code>try
  {
      using (Sqlconnection conn = new Sqlconnection) 
      {
          // codes select data from database
          ...
  
          // codes write file
          StreamWriter sw = new StreamWriter(filePath, true);
          sw.Write(aLongString);
          sw.Close();
  
          // codes update data in database
          ...
      }
  }
  catch {
      // codes send email here
  }
  </code></pre>