Exemplo n.º 1
0
        public IActionResult Index()
        {
            List <string> toReturn = new List <string>();

            foreach (var item in System.IO.File.ReadAllLines($@"{Environment.CurrentDirectory}\\App_Data\\Result_v5.txt", Encoding.GetEncoding("windows-1251")).ToList())
            {
                toReturn.Add(DeNcoder.Decrypt(item, "скорпион"));
            }
            return(View(toReturn));
        }
Exemplo n.º 2
0
        public IActionResult Saver(FileModel file)
        {
            string path = file.Path;

            if (!Directory.Exists(path))
            {
                ModelState.AddModelError("Path", "Такой директории не существует");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string decryptedText = DeNcoder.Decrypt(System.IO.File.ReadAllText($@"{Environment.CurrentDirectory}\\App_Data\\Result_v5.txt", Encoding.GetEncoding("windows-1251")), "скорпион");
                    System.IO.File.WriteAllText(Path.Combine(path, $"{file.Name}.txt"), decryptedText);
                    return(RedirectToAction("Index"));
                }
                catch
                {
                    ModelState.AddModelError("Name", "Может введено неверное имя?");
                }
            }
            return(View(file));
        }