title: Mvc5 fileupload and read excel content
body: <p>I'm trying to save and read from xls file using mvc5 and i got problem that saved file is not readable by excel... Can someone help me with this? Probly im missing something here.</p>
  
  <pre><code>public class ExcelFileUpload
  {
      [DisplayName("Wybierz plik excela")]
      [Required]
      public HttpPostedFileBase File { get; set; }
  }
  
      [HttpPost]
      public ActionResult Upload(ExcelFileUpload excel)
      {
          if (excel.File.FileName.Contains(".xls"))
          {
              var fileBytes = new byte[excel.File.ContentLength];
              var ms = new MemoryStream(fileBytes);
              var temp = Path.GetTempPath();
              var file = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
              var path = Path.Combine(temp, file + ".xls");
              using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write))
              {
                  ms.WriteTo(fs);
              }
              if (System.IO.File.Exists(path))
              {
                  var ei = new ExcelImporter(path);
                  ei.excel_getValue("A1");
  
              }
          }
          return View(excel);
      }
  </code></pre>