public IHttpActionResult UploadFileMedia() { try { // List<LogResponseDTO> lstErrores = new List<LogResponseDTO>(); var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { var fileSavePath = string.Empty; var docfiles = new List <string>(); var URLArchivo = ""; foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; // var filePath = HttpContext.Current.Server.MapPath("C:/UploadedFiles/"); var filePath = "C:/UploadedFiles/"; var GUID = Guid.NewGuid().ToString(); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } fileSavePath = Path.Combine(filePath, GUID + "." + postedFile.FileName.Split('.')[1]); postedFile.SaveAs(fileSavePath); docfiles.Add(filePath); // URLArchivo = "~/UploadedFiles/" + GUID + "." + postedFile.FileName.Split('.')[1]; URLArchivo = "C:/UploadedFiles/" + GUID + "." + postedFile.FileName.Split('.')[1]; string e = Path.GetExtension(URLArchivo); if (e != ".xlsx") { return(Ok(new { success = false, message = "La extencion del archivo no es valida" })); } } string FilePath = URLArchivo.Split('/')[2]; // var reader = new StreamReader(File.OpenRead(HttpContext.Current.Server.MapPath("~/UploadedFiles/") + FilePath), Encoding.GetEncoding(1252)); //var reader = new StreamReader(File.OpenRead(("C:/UploadedFiles/") + FilePath), Encoding.GetEncoding(1252)); TecnicaBl oTecnicaBl = new TecnicaBl(); var book = new ExcelQueryFactory(URLArchivo); var resultado = (from row in book.Worksheet("Base datos Instructores") let item = new Instructor_Tecnica { Cedula = row[1].Cast <string>(), Nombres = row[2].Cast <string>(), Apellidos = row[3].Cast <string>(), Correo_Misena = row[4].Cast <string>(), Correo_Alternativo = row[5].Cast <string>(), Municipio = row[6].Cast <string>(), Telefono_Fijo = row[7].Cast <string>(), Celular = row[8].Cast <string>(), Area = row[9].Cast <string>(), Profesion = row[10].Cast <string>(), Programa_Formacion = row[11].Cast <string>(), } select item).ToList(); bool vali = oTecnicaBl.GuardarInstructor(resultado); return(Ok(new { success = true, path = URLArchivo })); } else { return(Ok(new { success = false, message = "No File" })); } } catch (Exception exc) { return(Ok(new { success = false, message = exc.Message })); } }