Saturday, September 6, 2014

Store bytes conent to zip file in C#



You can store bytes in zip using the GZipStream object.

 
public static void CreateZipFromBytes(string fileName, byte[] bytesToCompress)

        {

            using (FileStream fileToCompress = File.Create(fileName))

            {

                using (GZipStream compressionStream = new GZipStream(fileToCompress, CompressionMode.Compress))

                {

                    compressionStream.Write(bytesToCompress, 0, bytesToCompress.Length);

                }

            }

        }

No comments:

Post a Comment