Zip File Class?

G

Guest

Hi,
Are there any classes in VB.NET or C# that allow for file compression,
similar to WinZip?
Thanks.
 
S

Siva M

There are no built-in classes in .NET 1.1. However, you can try this
open-source one: SharpLibZip

Hi,
Are there any classes in VB.NET or C# that allow for file compression,
similar to WinZip?
Thanks.
 
L

Lau Lei Cheong

Talking about this...

I've found some internet discussion on the possibility of using zipfldr.dll
come with Windows to do zipping, but seems all of them ended in telling the
OP to find 3rd party libraries.

Anyone knows if that is possible?

And as J# is made to make easy port of Java programs to the world of .NET, I
believe it should have some sort of functionality to manipulate JAR/ZIP
formats like Java. Can other .NET languages take advantage of these
routines?

Thank you for anyone answering these "maybe" questions.
 
J

Jon Skeet [C# MVP]

Lau Lei Cheong said:
I've found some internet discussion on the possibility of using zipfldr.dll
come with Windows to do zipping, but seems all of them ended in telling the
OP to find 3rd party libraries.

Anyone knows if that is possible?

It probably is, but it would be a lot more work than using SharpZipLib.
And as J# is made to make easy port of Java programs to the world of .NET, I
believe it should have some sort of functionality to manipulate JAR/ZIP
formats like Java. Can other .NET languages take advantage of these
routines?

Yes, but only if you have the J# assemblies installed - they're not
installed with a normal .NET installation.
 
O

Oliver Sturm

Jon said:
Not in the .NET framework itself (yet - there are in .NET 2.0),

Last time I looked, the stuff in .NET 2 was purely stream oriented - no
support for zip files in a way similar to SharpZipLib. Maybe that changed
recently?


Oliver Sturm
 
J

Jon Skeet [C# MVP]

Oliver Sturm said:
Last time I looked, the stuff in .NET 2 was purely stream oriented - no
support for zip files in a way similar to SharpZipLib. Maybe that changed
recently?

Not that I've heard - but if you've got compression on streams, and
streams which act on files, it's not exactly hard to put the two
together...
 
O

Oliver Sturm

Jon said:
Not that I've heard - but if you've got compression on streams, and
streams which act on files, it's not exactly hard to put the two
together...

I was assuming there was more to the zip file format than a sequence of
compressed byte streams - for example I was quite sure a zip file has a
"directory" of files somewhere. I might be wrong though, it's been a while
since I had a look at zip files in this detail :)


Oliver Sturm
 
J

Jon Skeet [C# MVP]

Oliver Sturm said:
I was assuming there was more to the zip file format than a sequence of
compressed byte streams - for example I was quite sure a zip file has a
"directory" of files somewhere. I might be wrong though, it's been a while
since I had a look at zip files in this detail :)

Ah, I see what you mean. Yes, you're right. I guess SharpZipLib has a
bit more life in it yet :)
 
W

William Stacey [MVP]

IIRC, gzip (even on unix) can gzip only one file - same as MS's stream. It
would not be too hard however, to come up with some kind of FAT and protocol
of your own to add multiple compressed files to same stream. Naturally that
would be proprietary, which propably makes it not so attractive.
 
J

Jon Skeet [C# MVP]

William Stacey said:
IIRC, gzip (even on unix) can gzip only one file - same as MS's stream. It
would not be too hard however, to come up with some kind of FAT and protocol
of your own to add multiple compressed files to same stream. Naturally that
would be proprietary, which propably makes it not so attractive.

That's true of gzip, but not zip. The zip file format is mostly
standardised, although I seem to remember that it has flaws such as not
supporting long filenames and non-ASCII characters terribly well. These
have been fixed by proprietary modifications to the format.
 
O

Oliver Sturm

William said:
IIRC, gzip (even on unix) can gzip only one file - same as MS's stream.
It would not be too hard however, to come up with some kind of FAT and
protocol of your own to add multiple compressed files to same stream.
Naturally that would be proprietary, which propably makes it not so
attractive.

Right, unless it's zip and everybody's been using it for years :) Plus
there are enough implementations of it around that you can't really call
it proprietary any more.

You're right about gzip, it's commonly used in conjunction with the tar
command to create files with the .tar.gz (or .tgz) extension - tar can
concatenate file streams and gzip compresses the whole bunch. This results
in a better overall compression rate but has the drawback that the whole
(compressed!) tar file has to be read to find a specific file that's
somewhere in the middle.


Oliver Sturm
 
W

William Stacey [MVP]

That's true of gzip, but not zip.

Right. I was refering to gzip only.
standardised, although I seem to remember that it has flaws such as not
supporting long filenames and non-ASCII characters terribly well. These
have been fixed by proprietary modifications to the format.

IIRC I had issues once unzipping some files that where zipped with
SharpZipLib and unzipping with another popular zip util. Did not end up
debugging to figure if it was SharpLibs issue or the tool, so I just dropped
it and did something else. Glad they at least included a gzip lib, that
will probably come in handy.
 
W

William Stacey [MVP]

Right, unless it's zip and everybody's been using it for years :) Plus
there are enough implementations of it around that you can't really call
it proprietary any more.

I agree. Zip is a defacto standard if anything is. I was talking if you
used gzip to come up with your own method to add multiple files. I assume
the reason they have not added a true zip lib may have something to do with
copyrights or money - not sure. The user need is definately exists.
You're right about gzip, it's commonly used in conjunction with the tar
command to create files with the .tar.gz (or .tgz) extension - tar can
concatenate file streams and gzip compresses the whole bunch. This results
in a better overall compression rate but has the drawback that the whole
(compressed!) tar file has to be read to find a specific file that's
somewhere in the middle.

:) I forgot about tar. I remember (ugg) hacking away at tar with various
success doing backups to tape. Those where the days :) I suppose my
suggestion was very similar to a tar/gzip combo. May be a fun project for
someone.
 
J

Jon Skeet [C# MVP]

William Stacey said:
I agree. Zip is a defacto standard if anything is. I was talking if you
used gzip to come up with your own method to add multiple files. I assume
the reason they have not added a true zip lib may have something to do with
copyrights or money - not sure. The user need is definately exists.

If by "money" you mean "implementation time" I suspect you're right. I
can't see how copyright would be an issue, as they've already got a
freely distributable implementation with the J# libraries.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top