I have used DeflateStream to compress a file like the code below:
string inputFilePath = Path.Combine(Environment.CurrentDirectory, "mamaSaid.mp3"); string outputFilePath = Path.Combine(Environment.CurrentDirectory, "mamaSaid.cmp"); FileStream inputFS = new FileStream(inputFilePath, FileMode.Open, FileAccess.Read); FileStream outputFS = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write); DeflateStream dfDest = new DeflateStream(outputFS, CompressionMode.Compress); int nextByte = inputFS.ReadByte(); while (nextByte != -1) { dfDest.WriteByte((byte)nextByte); nextByte = inputFS.ReadByte(); } dfDest.Close(); outputFS.Close();
|
but after I check the newly created file I see that it is much bigger than the original file?
what's wrong with my code?
Jisss shyamPosted Oct 21, 2009, 4:04 AM
check out this link
http://msdn.microsoft.com/en-us/library/bc2dbwea.aspx
thanks