| | |
Decompress large file
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2009
Posts: 39
Reputation:
Solved Threads: 0
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...
Your help is appreciated.
Thanks
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)
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
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.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
![]() |
Similar Threads
- Best File Compression Software? (Windows Software)
- Large File Support - Win32 (Python)
- Problem in reading a large file (C++)
- Large File Download (PHP)
- save ram file to hard disk,how? (Graphics and Multimedia)
- Telling users file is too large (PHP)
- Code not working for deleting recordfrom a file (Visual Basic 4 / 5 / 6)
- Having problems with a file type (Geeks' Lounge)
Other Threads in the C# Forum
- Previous Thread: On-the-fly automated file download
- Next Thread: Accessing a form's "close" button using win32 API
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml





