//string filename = "123.txt";
foreach (var files in Directory.GetFiles(pathToDir, "*.*", SearchOption.TopDirectoryOnly))
using (var fsIn = new FileStream(files, FileMode.Open, FileAccess.Read))
using (var fsOut = new FileStream($"{files}.crypt", FileMode.CreateNew, FileAccess.Write))
using (var aes = Aes.Create())
using (var enc = aes.CreateEncryptor(new byte[16] /* key */, new byte[16] /* vector */))
using (var cs = new CryptoStream(fsIn, enc, CryptoStreamMode.Write))
cs.CopyTo(fsOut);
It takes a long time to process large files, read that there is a MemoryMappedFile method that can process large files, tell me how you can use it in the code above ??