title: Filestream.readtimeout: invalid operation exception
body: <p>I want to download file (.PDF as an example) using File stream. Here is a contrived example:</p>
  
  <pre><code>public ActionResult GetPDF()
  {
      ActionResult ar = null;
      FileStream fs = null;
      try
      {
          fs = System.IO.File.OpenRead(filename);
          var bytes = new byte[fs.Length];
          var x = fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
          abcd fr = new abcd(fs, "application/pdf");
      }
      catch(Exception)
      {
      }
      return ar;
  }
  
  
  public class CheckedFileStreamResult : FileStreamResult
  {
      public bool DownloadCompleted { get; set; }
  
      public CheckedFileStreamResult(FileStream stream, string contentType)
          : base(stream, contentType)
      {
          DownloadCompleted = false;
      }
  
      protected override void WriteFile(HttpResponseBase response)
      {
          var outputStream = response.OutputStream;
          response.BufferOutput = false;
          using (FileStream)
          {
              var buffer = new byte[_bufferSize];
              var count = FileStream.Read(buffer, 0, _bufferSize);
              while (count != 0 &amp;&amp; response.IsClientConnected)
              {
                  outputStream.Write(buffer, 0, count);
                  count = FileStream.Read(buffer, 0, _bufferSize);
              }
              DownloadCompleted = response.IsClientConnected;
          }
      }
  
      private const int _bufferSize = 0x1000;
  }
  
  public class abcd : CheckedFileStreamResult
  {
      public abcd(FileStream stream, string contentType) : base(stream, contentType)
      {
          DownloadCompleted = false;
      }
  
      public void Write(HttpResponseBase response)
      {
          WriteFile(response);
      }
  }
  </code></pre>
  
  <p>I always get count with value 0. Invalid Operation Exception is thrown here:
  <code>var count = FileStream.Read(buffer, 0, _bufferSize);</code></p>
  
  <p>Please guide me how can I proceed. I want to know whether the file was downloaded successfully.</p>