943,097 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1285
  • C# RSS
Jun 5th, 2009
0

Decompress large file

Expand Post »
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...

C# Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
jonnytabpni is offline Offline
39 posts
since May 2009
Jun 6th, 2009
0

Re: Decompress large file

Have you tried using the SharpZip? It's probably much better at handling compression. http://www.icsharpcode.net/OpenSource/SharpZipLib/
Moderator
Reputation Points: 322
Solved Threads: 28
The C# Man, Myth, Legend
Tekmaven is offline Offline
914 posts
since Feb 2002

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Recognize and use spaces in multiline textbox
Next Thread in C# Forum Timeline: Accessing a form's "close" button using win32 API





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC