public ActionResult Index(HttpPostedFileBase file) { if (file.ContentLength > 0 && (Path.GetExtension(file.FileName) == ".mod" || Path.GetExtension(file.FileName) == ".erf")) { // Upload file var filename = Path.GetFileName(file.FileName); if (filename != null) { var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), filename); file.SaveAs(path); // Extract file var extractor = new ErfExtractor(); extractor.ExtractMod(Path.GetFullPath(path), Server.MapPath("~/App_Data/uploads/temp/")); } // Get area files _files = System.IO.Directory.EnumerateFiles(Server.MapPath("~/App_Data/uploads/temp"), "*.are").ToList(); for (var i = 0; i < _files.Count; i++) { _files[i] = Path.GetFileNameWithoutExtension(_files[i]); } TempData["Areas"] = _files; // Progress to next step return(RedirectToAction("AddAreas")); } else { return(RedirectToAction("Index")); } }
public ActionResult Index(HttpPostedFileBase file) { if (file.ContentLength > 0 && (Path.GetExtension(file.FileName) == ".mod" || Path.GetExtension(file.FileName) == ".erf")) { // Upload file var filename = Path.GetFileName(file.FileName); if (filename != null) { var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), filename); file.SaveAs(path); // Extract file var extractor = new ErfExtractor(); extractor.ExtractMod(Path.GetFullPath(path), Server.MapPath("~/App_Data/uploads/temp/")); } // Get area files _files = System.IO.Directory.EnumerateFiles(Server.MapPath("~/App_Data/uploads/temp"), "*.are").ToList(); for (var i = 0; i < _files.Count; i++) { _files[i] = Path.GetFileNameWithoutExtension(_files[i]); } TempData["Areas"] = _files; // Progress to next step return RedirectToAction("AddAreas"); } else { return RedirectToAction("Index"); } }