title: CSVHelper - No Output
body: <p>I am trying to create a csv file using the <code>CSVHelper</code> nuGet package</p>
  
  <p>This is the code</p>
  
  <pre><code>public ActionResult Test()
  {
      var ms = new MemoryStream();
      var sr = new StreamWriter(ms);
      var csv = new CsvWriter(sr);
  
      csv.WriteField("sd");
      csv.WriteField("sd");
      csv.WriteField("sd");
      csv.WriteField("sd");
  
      //ms.Seek(0, 0);
      sr.Flush();
      //ms.Position = 0;
      var len = ms.Length;
  
      return File(ms, "text/csv", "test.csv");
  }
  </code></pre>
  
  <p>However, the file is always blank</p>
  
  <p>I have read several questions on here that suggest the <code>StreamWriter</code> needs to be flushed. The position moved to 0. However, Ive tried that and it doesnt seem to work </p>
  
  <p>I have also tried the same with <code>using</code> statements for the <code>MemoryStream</code>, <code>StreamWriter</code> and <code>CSVWriter</code>
  I've tried all of these and it is still blank</p>
  
  <p>Whatsmore, the length of the <code>MemoryStream</code> is always zero </p>
  
  <p>What am I doing wrong?</p>