title: Excel file (.xlsx) created by saving byte stream in C# cannot be opened
body: <p>I am attempting to save an Excel (.xlsx) file in disk that is sent to a webservice. The code I have used is as follows, However when I click on the saved file it returns a "The File is corrupt and cannot be opened" error. But the same methodology works for CSV files.</p>
  
  <pre><code>  string dataFile = await Request.Content.ReadAsStringAsync();
    byte[] byteArray = Encoding.UTF8.GetBytes(dataFile);
    MemoryStream stream_ = new MemoryStream(byteArray);
    MultipartParser.MultipartParser mp = new MultipartParser.MultipartParser(stream_);
  
    // Save Excel file
    File.WriteAllBytes(@"C:\temp\output.xlsx", mp.FileContents);
  </code></pre>