title: writing to file implementation
body: <p>I just want to learn something new here about my code.</p>
  
  <p>I have the following function ,is it the optimized way to return if I had a problem during writing to a file? or there is a better way doing so..</p>
  
  <pre><code>public static bool WriteFile(ByteBuffer data  , String fileName, bool append)
          {
              var writer = new StreamWriter(fileName, append);
              var errorVal = true;
              try
              {
                  writer.Write(data);
                  writer.Flush();
              }
              catch (Exception ex)
              {
  
                  errorVal = false;
              }
              finally
              {
                  writer.Dispose();
              }
  
              return errorVal;
          }
  </code></pre>