Exemplo n.º 1
0
        private async Task TransferElement(string pathToFile)
        {
            var aesAlg    = Aes.Create();
            var addedFile = new FileElement(pathToFile);

            MakeRecord($"1 was added.\n");
            AwaitFileToClose(addedFile.Info.FullName);
            if (enableEncrypting)
            {
                MakeRecord($"2 was added.\n");
                await addedFile.EncryptAsync(aesAlg);

                MakeRecord($"{pathToFile} was encrypted.\n");
            }

            var compressedFile = new FileElement(await addedFile.CompressAsync(targetDir, archiveOptions));

            MakeRecord($"{pathToFile} was compressed.\n");

            var decompressedFile = new FileElement(await compressedFile.DecompressAsync(targetDir));

            MakeRecord($"{decompressedFile.Info.FullName} was moved.\n");

            if (enableEncrypting)
            {
                await decompressedFile.DecryptAsync(aesAlg);

                MakeRecord($"{decompressedFile.Info.FullName} was decrypted.\n");
                await addedFile.DecryptAsync(aesAlg);
            }

            if (enableArchiveDir)
            {
                compressedFile.Move(archivedFilesDir);
            }
            ;
            SortFiles(decompressedFile);
        }