public async Task <IActionResult> Decipher(IFormFile file, [FromForm] Key key) { CreateDirectory(); var ExtensionFile = ""; ExtensionFile = Path.GetExtension(file.FileName); switch (ExtensionFile) { case ".zz": ZigZag.Decifrar(file, key.levels); break; case ".csr": Cesar.Decifrar(file, key.word); break; case ".rt": Route.DecifradoEspiral(file, key.columns, key.rows); break; default: return(StatusCode(StatusCodes.Status500InternalServerError)); break; } var path = Environment.CurrentDirectory + "\\temp\\" + Path.GetFileNameWithoutExtension(file.FileName) + ".txt"; var Memory = new MemoryStream(); using (var Stream = new FileStream(path, FileMode.Open)) { await Stream.CopyToAsync(Memory); } Memory.Position = 0; var extensionFile = Path.GetExtension(path).ToLowerInvariant(); DeleteDirectoy(); return(File(Memory, GetMimeTypes()[extensionFile], Path.GetFileName(path))); }