Пример #1
0
        public static void Decompress(string compressedSource, string FileName)
        {
            FileStream sourceStream = new FileStream(compressedSource, FileMode.OpenOrCreate);

            string targetSource = (compressedSource.Remove(compressedSource.LastIndexOf(".gz")) + ".txt").Insert(15, "Archive");

            File.WriteAllText("C:\\Games\\Textos.txt", targetSource);

            string newName = "\\" + FileName.Remove(FileName.LastIndexOf(".crypt")) + ".txt";

            File.WriteAllText("C:\\Games\\Textossss.txt", newName);

            string directory = targetSource.Remove(targetSource.LastIndexOf(newName));

            Directory.CreateDirectory(directory);

            using (FileStream targetStream = File.Create(targetSource))
            {
                // поток разархивации
                using (GZipStream decompressionStream = new GZipStream(sourceStream, CompressionMode.Decompress))
                {
                    decompressionStream.CopyTo(targetStream);
                }
            }

            DeCrypt.Decrypt(targetSource);
        }
Пример #2
0
        public void addFile()
        {
            string path          = this.CreateFolders();
            string newNameOfFile = $"\\Sales_{Infa.CreationTime.Year}_{Infa.CreationTime.Month}" +
                                   $"_{Infa.CreationTime.Day}_{Infa.CreationTime.Hour}" +
                                   $"_{Infa.CreationTime.Minute}_{Infa.CreationTime.Second}";
            string fullPath = path + newNameOfFile;

            File.Copy(Source + NameOfFile, fullPath, true);
            File.Delete(Source + NameOfFile);
            (string cryptPath, string cryptName) = DeCrypt.CryptFile(fullPath);
            File.Delete(fullPath);
            string compressSource = Compressor.Compress(cryptPath, cryptName);

            Compressor.Decompress(compressSource, cryptName);
        }