Click here to Skip to main content
Click here to Skip to main content

Zip and Unzip from a C# program using J# runtime

, 25 Apr 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
Zip and Unzip from a C# program using


There are a lot of libraries to work with zip files. I found a very easy way to work with zip files from a C# program. The Microsoft .Net Framework 1.1 comes with new language: J#. Let's look at it a little. For sure, Java is a parent of it; if so, is somewhere here! I spent a few minutes and found it in vjslib.dll. Let's do the work. Start a new C# project and select Windows Application. Our goal is something like that:

All we need to do is: add reference to our project:

Now, we can use it:

// Output stream fos = new; 

// Tie to zip stream zos = new; 

// Stream with source file fis = new; 

// It's our entry in zip ze = new; 

sbyte[] buffer = new sbyte[1024]; 
int len; 

// Read and write until done 
while((len = >= 0) 
    zos.write(buffer, 0, len); 
// Close everything 


That's all! Demo application is included.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Valeri Makarov
Software Developer
Russian Federation Russian Federation
Over 12 years of experience as a Software Developer/Engineer, development and production support applications for MS DOS, MS Windows.
Certified C Programmer
Certified C++ Programmer
Certified Visual FoxPro Programmer
Certified C# Programmer

Comments and Discussions

GeneralRe: What about multiple folders? PinmemberElmue31-Dec-05 2:53 
GeneralRe: What about multiple folders? Pinmemberwyattda17-Jan-06 18:36 
GeneralRe: Alternative (with code) Pinmemberchris1755-Dec-06 5:49 
GeneralAble to zip directories and their contents Pinmembernicholaskeytholeong26-Aug-05 20:01 
Hi Valeri, I have finally came out with the algorithm to zip a particular folder and it's content which includes the subfolders and the files that are located in both the folder and the subfolders.
I have been searching for an example to zip a folder without using the opensource library (SharpZipLib) but I can't find any. Then, I decided to write the codes myself in the end. It took me a few lines to do both zip and unzip folder operation as well as zipping and unzipping files. wooohoooo yay.
I shall share my codes to the viewers soon. Big Grin | :-D

GeneralRe: Able to zip directories and their contents Pinmemberobinna_eke30-May-06 2:29 
GeneralRe: Able to zip directories and their contents Pinmembersanjayg1233-Mar-07 22:59 
GeneralZipping folders and their subdirectories Pinsussnicholaskey12-Aug-05 18:39 
GeneralRe: Zipping folders and their subdirectories Pinmembernicholaskeytholeong12-Aug-05 18:42 
GeneralThank You PinmemberSeth O'Neal6-May-05 8:37 
GeneralThere is a bug in those classes PinstaffNishant S9-May-04 4:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 26 Apr 2004
Article Copyright 2004 by Valeri Makarov
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid