Compression Using GZipStream

Compression is very much important in many cases.We can even compress our ViewState so that we can increase the performance of application Here i am going to give code snippets for compression using GZipStream.

FileStream inStream = File.OpenRead(inputFileName);
FileStream outStream = File.Create(outputFileName);
GZipStream gZipStream = new GZipStream(outStream, CompressionMode.Compress);

int bytes = inStream.ReadByte();

while (bytes1 = -1)
gZipStream.WriteByte(bytes as byte);
bytes = inStream.ReadByte();



No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: