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

QuestionWhat about cyrillics? Pinmemberchien-andalou16-Jul-09 6:32 
GeneralHanging onto corrupt file Pinmemberterry summers22-Mar-09 11:16 
Hi and thank you very much for the informative article.
I have one problem with this which I cannot figure out.
I'm using this to unzip some files. Pretty basic really.
In testing I gave it a corrupt file (to be able to trap the error and rename the zip as a bad zip file)
It gets as far as ZipFile zipfile = new ZipFile(ZipFileName);
The error gets trapped, however the class is still hanging onto the file so I can't rename it (or in fact do anything with it) until I shut down the program.
Would you know what would be holding onto the file?
Thanks in advance,
Questionunzipped progress status Pinmemberbyteway2-Oct-07 22:38 
QuestionUnzip file stored in database Pinmembermikebiro1-Oct-07 13:11 
QuestionCan I zip without folder structure? Pinmemberjupinno_ys15-Aug-07 22:57 
AnswerRe: Can I zip without folder structure? PinmemberPranaySharma8427-Aug-07 4:55 
GeneralProblem in unzip Pinmemberhamidreza Talebi7-Aug-07 2:18 
QuestionSize of Zipped File Pinmemberkyreddy26-Jun-07 5:00 
Generalzip files with password PinmemberMember #112974824-Feb-07 3:21 
GeneralRe: zip files with password PinmemberValeri18-Apr-07 20:47 

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
Web03 | 2.8.150327.1 | Last Updated 26 Apr 2004
Article Copyright 2004 by Valeri Makarov
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid