| | |
Decompress large file
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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 2007 access algorithm appportability array bitmap box c# camera check checkbox client combobox control conversion cryptographyc#winformsencryption cs4 csharp customactions database datagrid datagridview dataset date datetime degrees disabled displayingopenforms draganddrop drawing encryption enum eventcloseformc# excel file form format forms ftp function gdi+ image index index-error input install java list listview load mailmerge math mathematics mouseclick mysql operator path photoshop picturebox pixelinversion pixels post prime programming radians regex remoting resolved. richtextbox rotation search security server setup sleep socket sockets sql statistics stream string table text textbox thread time timer totaldays transparency update user usercontrol validation view visual visualstudio wordautomation wpf xml





