0
Reply

About Compressing using GZipStream

Don

Don

Feb 14 2007 9:35 AM
1.8k
hi guys .. , I have the following code from book MCTS 70-536 ( Self paced training kit by Mcft Press) Microsoft .NET 2.0 Application Development Foundation .. In lesson 3 "Compressing Streams " of Chapter 2 Input/Output .... using System; using System.Collections.Generic; using System.Text; using System.IO; using System.IO.Compression; namespace CompressDe { class Program { static void Main(string[] args) { FileStream sourceFile = File.OpenRead(@"C:\anyFile.txt"); FileStream destFile = File.Create(@"C:\anyFile.txt.gz"); GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress); int theByte = sourceFile.ReadByte(); while (theByte != -1) { compStream.WriteByte((byte)theByte); theByte = sourceFile.ReadByte(); } } } The problem with the following code is that the Size of the Compressed File comes out to be larger than the original file .... then what is the profit of compressing the file . . Edit/Delete Message