|
-
February 14th, 2007, 09:33 AM
#1
About Compressing using GZipStream
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 . .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|