PC Review


Reply
Thread Tools Rate Thread

compression issues

 
 
csharpula csharp
Guest
Posts: n/a
 
      28th Oct 2008
Hello,

I would like to know which one of the following compressiom methods are
the easiest to implement in c# and the most effective one in compression
of files? (text or code files)

Which one of those: zip, tar, tar.gz, gz. ?
And is there any code sample in C# of the API with compression?

Thank you!



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      28th Oct 2008

"csharpula csharp" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hello,
>
> I would like to know which one of the following compressiom methods are
> the easiest to implement in c# and the most effective one in compression
> of files? (text or code files)
>
> Which one of those: zip, tar, tar.gz, gz. ?
> And is there any code sample in C# of the API with compression?
>


using System;
using System.IO;
using System.IO.Compression;

void static GZFile(string source, string destination)
{
using (
Stream src = File.Open(source, FileMode.Open),
dst = File.Open(destination, FileMode.Create) )
{
Stream gz = new GZipStream(dst, CompressionMode.Compress);
Pump(src, gz);
gz.Flush();
gz.Close();
}
}

This will create a gz file. Note Pump (code not shown) simply chunks a 128K
buffer from one stream to another.

It doesn't get any simpler. However other third party libraries would
probably get better compression.


--
Anthony Jones - MVP ASP/ASP.NET

 
Reply With Quote
 
DaveL
Guest
Posts: n/a
 
      28th Oct 2008
http://www.codeplex.com/DotNetZip



"csharpula csharp" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hello,
>
> I would like to know which one of the following compressiom methods are
> the easiest to implement in c# and the most effective one in compression
> of files? (text or code files)
>
> Which one of those: zip, tar, tar.gz, gz. ?
> And is there any code sample in C# of the API with compression?
>
> Thank you!
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
 
csharpula csharp
Guest
Posts: n/a
 
      28th Oct 2008


But which one is the most efficent and how to API with it from C#?

Thanks a lot!

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
rhaazy
Guest
Posts: n/a
 
      28th Oct 2008
On Oct 28, 1:15*pm, csharpula csharp <csharp...@yahoo.com> wrote:
> But which one is the *most efficent and how to API with it from C#?


Figure it out, do some research, its not hard to do a couple of google
searches about comparisons between compression methods.
Someone gave you the code you would need, what do you mean how to API
with it from c#?
>
> Thanks a lot!
>
> *** Sent via Developersdexhttp://www.developersdex.com***


 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      28th Oct 2008
csharpula csharp wrote:
> I would like to know which one of the following compressiom methods are
> the easiest to implement in c# and the most effective one in compression
> of files? (text or code files)
>
> Which one of those: zip, tar, tar.gz, gz. ?
> And is there any code sample in C# of the API with compression?


Tar is not compressing at all - it just bundles multiple files
in one file.

Zip and gzip basically use the same compression algorithm
(a combination of LZ77 with Huffman encoding and some
smart tricks). Zip format has the capability to bundle
multiple files in one file - gzip does not.

..NET framework support:
- the basic algorithm
- gzip
in namespace System.IO.Compression !

To get zip you will need something extra like:
- SharpZipLib
- J# runtime library from Microsoft

Arne
 
Reply With Quote
 
csharpula csharp
Guest
Posts: n/a
 
      29th Oct 2008
So that means that tar.gz and zip are the same from the compression
point of view?





*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      29th Oct 2008
csharpula csharp wrote:
> So that means that tar.gz and zip are the same from the compression
> point of view?


They use the exact same compression algorithm, but you get
different resulting sizes.

Tar creates a bundle of all the files uncompressed and then
gzip compresses it and just add a tiny header.

Zip bundles and compress all the files individually.

This means that:
- a .tar.gz will often be sligtly smaller than the .zip because
you get better compression when you compressed everything
in one pass instead of compressing each file individually
- you can extract a single file from a zip while with a
.tar.gz even though it may look as if you extract a single
file then in fact you are decompressing the entire thing
(or at least up to where the exacted file are)

I don't know if that makes it same or different in your context.

Arne
 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      2nd Nov 2008
"Arne Vajhøj" <(E-Mail Removed)> wrote in message
news:4907819f$0$90266$(E-Mail Removed)...
> csharpula csharp wrote:
>> I would like to know which one of the following compressiom methods are
>> the easiest to implement in c# and the most effective one in compression
>> of files? (text or code files)
>>
>> Which one of those: zip, tar, tar.gz, gz. ? And is there any code sample
>> in C# of the API with compression?

>
> Tar is not compressing at all - it just bundles multiple files
> in one file.
>
> Zip and gzip basically use the same compression algorithm
> (a combination of LZ77 with Huffman encoding and some
> smart tricks). Zip format has the capability to bundle
> multiple files in one file - gzip does not.
>
> .NET framework support:
> - the basic algorithm
> - gzip
> in namespace System.IO.Compression !
>
> To get zip you will need something extra like:
> - SharpZipLib
> - J# runtime library from Microsoft
>


Another Zip option would be System.IO.Packaging.Package which is
fundementally a Zip file.

--
Anthony Jones - MVP ASP/ASP.NET

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compression with .Net 2.0 vincent Microsoft Dot NET 0 11th Apr 2006 10:38 AM
Download issues: File Format/Compression, etc. Paul Engel Windows XP Music 5 30th Sep 2004 05:11 PM
Zip/Compression in .NET RAJ Microsoft ASP .NET 8 8th Aug 2004 07:03 AM
Picture compression issues in Outlook 2003 akg Microsoft Outlook 2 25th Oct 2003 07:50 PM
Re: compression Mike Kolitz Windows XP General 0 1st Oct 2003 11:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:35 PM.