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.
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);