Tuesday, January 20, 2009

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();
}

:-)

0 comments:

Post a Comment