Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / June 2007

Tip: Looking for answers? Try searching our database.

File compression in .NET - for very large files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Amit Dedhia - 21 Jun 2007 08:12 GMT
Hi

I want to compress and decomress files. There is GZipStream class
in .Net. However this class requires to allocate buffer equal to the
file length to zip it (at least all sample code I saw were like that).
The file size in my case can be really very large and hence I want
something which does not require to load entire file in memory. Is
there any way?

Thanks and best regards
Amit Dedhia
Mark Rae - 21 Jun 2007 08:20 GMT
> Is there any way?

http://www.chilkatsoft.com/zip-dotnet.asp

Signature

http://www.markrae.net

Jon Skeet [C# MVP] - 21 Jun 2007 08:39 GMT
> > Is there any way?
>
> http://www.chilkatsoft.com/zip-dotnet.asp

There's no need to go into commercial software here - the only problem
for the OP is that all the samples read the whole of the data into
memory before pumping any of it through the output stream. That's easy
to fix and worth knowing for other situations too :)

Jon
Jon Skeet [C# MVP] - 21 Jun 2007 08:21 GMT
> I want to compress and decomress files. There is GZipStream class
> in .Net. However this class requires to allocate buffer equal to the
> file length to zip it (at least all sample code I saw were like that).
> The file size in my case can be really very large and hence I want
> something which does not require to load entire file in memory. Is
> there any way?

You don't need to read the whole file in. Just copy the data from the
input stream to the GZipStream a chunk (eg 32K) at a time.

I've got a utility class which makes this easier:
http://pobox.com/~skeet/csharp/miscutil
and
http://pobox.com/~skeet/csharp/miscutil/usage/streamutil.html
in particular.

Jon

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.