public IActionResult DownloadTxt(string result) { if (result != null) { byte[] byteArray = Encoding.UTF8.GetBytes(result); MemoryStream stream = new MemoryStream(byteArray); return(File(stream, FuncSupply.GetContentType("fff.txt"), Path.GetFileName("Result.txt"))); } else { return(NoContent()); } }
public IActionResult Index(IFormFile file, string text, string typee, string mes) { if (mes == null) { var fileName = Path.GetFileName(file.FileName); string tex = string.Empty; var ext = Path.GetExtension(fileName).ToLowerInvariant(); if (ext == ".docx" || ext == ".txt") { if (ext == ".docx") { using (var uploadedFile = file.OpenReadStream()) using (var wordyDocument = WordprocessingDocument.Open(uploadedFile, false)) { tex = wordyDocument.MainDocumentPart.Document.Body.InnerText; } } else { using (var uploadedFile = file.OpenReadStream()) using (var reader = new StreamReader(uploadedFile, Encoding.UTF8)) { tex = reader.ReadToEnd(); } } } if (typee.Contains("ye")) { TempData["res"] = FuncSupply.Decrypt(tex, text); } else { TempData["res"] = FuncSupply.Encrypt(tex, text); } } else { if (typee.Contains("ye")) { TempData["res"] = FuncSupply.Decrypt(mes, text); } else { TempData["res"] = FuncSupply.Encrypt(mes, text); } } return(RedirectToAction("Index")); }