Zip Files In C#

D

Doug

Hi,

I need to write some functionality in C# that will zip files. I've
been doing some reading of previous posts and saw some good info but
I'm bound by the following restrictions:

1) I may not be able to use a third party tool - we have some
restrictions on this.
2) I can't use J#.
3) I don't have Visual Studio .NET 2005 (we're currently still using
1.1).

Is there some way I can write code myself in C# with 1.1 and be able to
zip files? Or do my restrictions pretty much prevent me from doing
this?
 
M

Marc Gravell

If this was me, I'd want to have #1 *very* well defined:
I may not be able to use a third party tool - we have some
restrictions on this.

It isn't clear what this means... bought-in? CLR only?

The CLR offers a few /stream/ compression classes, but not zip, which
is a more complex structure of multiple compressed streams along with
file headers. SharbZipLib would be the obvious choice here; the license
is fairly open. Else perhaps Process.Start to existing command-line
tools (e.g. the aging pkzip, what else?)...

Otherwise, you are going to be writing (and testing) a lot of very risk
stuff. And why?

Sorry I don't have a better answer,

Marc
 
S

Shawn Wildermuth (C# MVP)

Hello Doug,

There are a number of 3rd party tools (some even free...like beer), but I
can't suggest any until I understand your restrictions on 3rd party tools.
I am not sure it can be done without a 3rd party component. You can do
compression but probably not in the .zip format.


Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
 
J

Jon Skeet [C# MVP]

Shawn Wildermuth said:
There are a number of 3rd party tools (some even free...like beer), but I
can't suggest any until I understand your restrictions on 3rd party tools.
I am not sure it can be done without a 3rd party component. You can do
compression but probably not in the .zip format.

Well, there's nothing to stop the OP from performing the same level of
implementation that the SharpZipLib team did. It will, however, take a
very long time and is unlikely to end up as well tested as SharpZipLib
(just through being used by fewer people).
 
D

Doug

Shawn/Marc - We can use third party tools but we're pretty limited, it
requires a pretty heavy research process to get approval for them (it
took me nearly a year to get NUnit approved!!) So I'm a little
hesitant to use third party tools unless I have no other option.

Greg, you had mentioned copying the code from zSharpLib. Is that okay
to do? I am not familiar with all the rules involved with open source
code.

Marc - I had read the codeproject.com article you referenced, but I
couldn't determine what reference to add to get the "Shell32" code to
work?
 
M

Marc Gravell

To quote from the article:

"To make this code work, you will also need to set a reference to a COM
library. In the References window, go to the COM tab and select the
library labeled 'Microsoft Shell Controls And Automation'."

Marc
 
B

Barry Kelly

Shawn Wildermuth (C# MVP) said:
Hello Doug,

There are a number of 3rd party tools (some even free...like beer), but I
can't suggest any until I understand your restrictions on 3rd party tools.
I am not sure it can be done without a 3rd party component. You can do
compression but probably not in the .zip format.

Of course it can be done without a 3rd party component - one can always
roll one's own - it's just a question of economic efficiency!

Zip files use 'gzip' (available through GZipStream) compression
internally, but they also have header and directory information that
need to be maintained. It's the management of the headers and
directories that .NET doesn't have natively.

-- Barry
 
G

Greg Young

I think it would be better to question the policy of making you rewrite open
source code as there is no good reason why you wouldn't use it as is ... A
3rd party control argument can be made in regards to buying controls or in
using controls that are not open source as you may end up at the mercy of
whoever is maintaining it but with open source ... you have source.

Cheers,

Greg
 

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