Tuesday, May 16, 2006

Dynamically create zip files programmatically using .NET

One of my collegue was enquiring whether we could zip a folder of files programmatically using .NET. Though I told him its possible, I couldn't remember the URL where I have read about it in MSDN.

To be frank the first option which came to my mind was to use some third party components to do this task. But after little bit of googling I was able to find out the exact URL which explains the way to do it without using any third party components.

If at all you are also interested in that check out this MSDNMag article.

Extract:

Zip compression lets you save space and network bandwidth when storing files or sending them over the wire. In addition, you don't lose the directory structure of folders you Zip, which makes it a pretty useful compression scheme. The C# language doesn't have any classes that let you manipulate Zip files, but since .NET-targeted languages can share class implementations, and J# exposes classes in the java.util.zip namespace, you can get to those classes in your C# code.
This article explains how to use the Microsoft J# class libraries to create an application in C# that compresses and decompresses Zip files. It also shows other unique parts of the J# runtime you can use from any .NET-compliant language to save some coding.

4 comments:

Prem said...

Vadivel, Good One it is working fine. Thanks man...

Vadivel said...

Most welcome prem :)

Anonymous said...

Another approach is to use
SharpZipLib
, pure C#.

Jason

Alex said...

For solve similar problems I recommend to use this tool-open broken zip files,it has many resources and has free status as far as I can see,it can work under all supported versions of this operating system,extremely easy to use, when the program is installed, you can see a file selection dialog, you can choose any file with *.zip extension, including self-extracting archives,program has a powerful engine, that can work with several different algorithms of analysis, it features an easy graphic interface, that will easily guide you through several simple steps of recovery process,tool can work with password-protected files.