Answers for "stream deflator c#"

C#
1

stream deflator c#

using System;
using System.IO;
using System.IO.Compression;

public class Program
{
    public static void Compress(DirectoryInfo directorySelected)
    {
      using (FileStream compressedFileStream = File.Create(file.FullName + ".cmp"))
      {
        using (DeflateStream compressionStream = new DeflateStream(compressedFileStream, CompressionMode.Compress))
        {
          originalFileStream.CopyTo(compressionStream);
        }
      }
    }

    public static void Decompress(FileInfo fileToDecompress)
    {
      using (FileStream decompressedFileStream = File.Create(newFileName))
      {
        using (DeflateStream decompressionStream = new DeflateStream(originalFileStream, CompressionMode.Decompress))
        {
          decompressionStream.CopyTo(decompressedFileStream);
          Console.WriteLine("Decompressed: {0}", fileToDecompress.Name);
        }
      }
    }
}
Posted by: Guest on July-31-2020

C# Answers by Framework

Browse Popular Code Answers by Language