Decompress large file

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: May 2009
Posts: 39
Reputation: jonnytabpni is an unknown quantity at this point 
Solved Threads: 0
jonnytabpni jonnytabpni is offline Offline
Light Poster

Decompress large file

 
0
  #1
Jun 5th, 2009
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...

  1. protected void Decompress(string filePath,string fileout)
  2. {
  3. FileStream sourceFile = File.OpenRead(filePath);
  4. FileStream destinationFile = File.Create(fileout);
  5. GZipStream unzip = null;
  6. byte[] buffer = new byte[sourceFile.Length];
  7. try
  8. {
  9. unzip = new GZipStream(sourceFile, CompressionMode.Decompress, false);
  10. int numberOfBytes = unzip.Read(buffer, 0, buffer.Length);
  11.  
  12. destinationFile.Write(buffer, 0, numberOfBytes);
  13. }
  14. catch (Exception ex)
  15. {
  16. MessageBox.Show(ex.Message);
  17. }
  18. finally
  19. {
  20. sourceFile.Close();
  21. destinationFile.Close();
  22. unzip.Close();
  23. }
  24. }

Your help is appreciated.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 898
Reputation: Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light 
Solved Threads: 28
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend

Re: Decompress large file

 
0
  #2
Jun 6th, 2009
Have you tried using the SharpZip? It's probably much better at handling compression. http://www.icsharpcode.net/OpenSource/SharpZipLib/
-Ryan Hoffman

.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC