Hi Folks,

I'm using this code I found online to decompress a large file. It works fine when I try it with a small file i.e. a 5MB mp3 (1.7MB compressed) but when I try and use it with a 250MB file (27MB compressed), the newly created output file is the same size as the input compressed file (AFAIK, it is probably a copy). I have tried this on a machine with 256MB of RAM and a machine with 4GB of RAM...

protected void Decompress(string filePath,string fileout)
        {
            FileStream sourceFile = File.OpenRead(filePath);
            FileStream destinationFile = File.Create(fileout);
            GZipStream unzip = null;
            byte[] buffer = new byte[sourceFile.Length];
            try
            {
                unzip = new GZipStream(sourceFile, CompressionMode.Decompress, false);
                int numberOfBytes = unzip.Read(buffer, 0, buffer.Length);

                destinationFile.Write(buffer, 0, numberOfBytes);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                sourceFile.Close();
                destinationFile.Close();
                unzip.Close();
            }
        }

Your help is appreciated.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.