Create ZIP files from .NET applications

The .NET System.IO namespace lets you perform most file system operations easily unless you want to compress or ZIP a file. Why couldn't the framework's Copy function simply include a Compress option? You can use NTFS file compression (see my sample) but this doesn't compress the file a heck of a lot.

A better approach is to invoke functionality from the Visual J# library. The link below allows you to download a working C# sample that I found on the web. I don't think there are any issues with me making it available here. Search for SharpZip in Google for the complete sample and a thorough discussion.

Basically, in your C# application you reference the Java Runtime vsjlib.dll and use the functionality in the java.util and java.util.zip namespaces.

The sample includes a lot of code, most of which is dedicated to the user interface. The code required to zip files is actually pretty straight forward and can easily be adapted to your needs.

Download the code




About TheScarms
About TheScarms


Sample code
version info

If you use this code, please mention "www.TheScarms.com"

Email this page


© Copyright 2024 TheScarms
Goto top of page