4
I have following code:
        [HttpPost]
        public ActionResult importCSV(HttpPostedFileBase file)
        {
            if (file.ContentLength <= 0)
            {
                ViewBag.Message = "Nenhum arquivo foi enviado.";
                return View("index");
            }
                try
                {
                    string arquivo = Path.Combine(Server.MapPath("/ArquivosImportados"), Path.GetFileName(file.FileName));
                    string tipo = Path.GetExtension(arquivo);
                    if (tipo == ".csv")
                    {
                        file.SaveAs(arquivo);
                        ViewBag.Message = "Sucesso ao enviar arquivo! " + tipo;
                    }
                    else
                    {
                        ViewBag.Message = "O arquivo enviado não foi reconhecido com .csv válido!";
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.Message = "ERRO: " + ex.Message.ToString();
                }
            return View("index");
        }
Is it possible to read the CSV file without having to save it? How can I read it?
Good Tips. You’re a myth man!
– Jedaias Rodrigues