UnZip Text string - CSharp System.IO.Compression

CSharp examples for System.IO.Compression:Zip

Description

UnZip Text string

Demo Code


using System.Text;
using System.IO.Compression;
using System.IO;//from   www  .  j a  v a  2 s .c o m
using System.Collections.Generic;
using System;

public class Main{
        public static string UnZipText(string compressedText)
        {
            StringBuilder result = new StringBuilder();
            byte[] compressedBinary = Convert.FromBase64String(compressedText);
            byte[] destinBinary = UnZipBinary(compressedBinary);

            foreach (var byt in destinBinary)
                result.Append(Convert.ToChar(byt));

            return result.ToString();
        }
        public static byte[] ZipBinary(byte[] rawSource)
        {
            memDestination = new MemoryStream();
            memSource = new MemoryStream(rawSource);
            gzipStream = new GZipStream(memDestination, CompressionMode.Compress);

            Streamer.CopyStream(memSource, gzipStream);

            gzipStream.Close();

            return memDestination.ToArray();
        }
}

Related Tutorials