I have an excel file stored in VARBINARY currently at ID 1. I need to replace this file with an updated version, that has to remain at ID 1. My solution below does replace the byte[] content, but the updated file is unreadable. Any ideas? - ReadFileFully just returns a byte array from a memory stream.
public ActionResult ReplaceFORATVersion()
{
string file_name = "C:\\Calculation Engine FORAT.xls";
FileStream fs = new FileStream(file_name, FileMode.Open, FileAccess.Read);
var excelObj = db.FPTExcel.OfType<FPTFORATExcel>().Where(e => e.Id == 1).FirstOrDefault();
excelObj.Content = ExcelManager.ReadFileFully(fs);
db.SaveChanges();
return RedirectToAction("Index", "AdminData");
}