Click here to Skip to main content
11,414,234 members (69,992 online)
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? Pin
chien-andalou, 16-Jul-09 6:32
memberchien-andalou16-Jul-09 6:32 
GeneralHanging onto corrupt file Pin
terry summers, 22-Mar-09 11:16
memberterry summers22-Mar-09 11:16 
Questionunzipped progress status Pin
byteway, 2-Oct-07 22:38
memberbyteway2-Oct-07 22:38 
QuestionUnzip file stored in database Pin
mikebiro, 1-Oct-07 13:11
membermikebiro1-Oct-07 13:11 
QuestionCan I zip without folder structure? Pin
jupinno_ys, 15-Aug-07 22:57
memberjupinno_ys15-Aug-07 22:57 
AnswerRe: Can I zip without folder structure? Pin
PranaySharma84, 27-Aug-07 4:55
memberPranaySharma8427-Aug-07 4:55 
GeneralProblem in unzip Pin
hamidreza Talebi, 7-Aug-07 2:18
memberhamidreza Talebi7-Aug-07 2:18 
QuestionSize of Zipped File Pin
kyreddy, 26-Jun-07 5:00
memberkyreddy26-Jun-07 5:00 
Hi,this is a good stuff .Bt zipped files size is same as the total size of the zipped files.Can you suggest me wat should i do to get some compressed in size for zip file.
Generalzip files with password Pin
Member #1129748, 24-Feb-07 3:21
memberMember #112974824-Feb-07 3:21 
GeneralRe: zip files with password Pin
Valeri, 18-Apr-07 20:47
memberValeri18-Apr-07 20:47 
GeneralRe: zip files with password Pin, 6-Jun-07 10:05
memberamit_2006_it@yahoo.com6-Jun-07 10:05 
GeneralRe: zip files with password Pin
Valeri, 7-Jun-07 8:13
memberValeri7-Jun-07 8:13 
QuestionHow to unzip password protected zip files? Pin
sakthivenkatesh, 22-Feb-07 14:04
membersakthivenkatesh22-Feb-07 14:04 
AnswerRe: How to unzip password protected zip files? Pin
Valeri, 18-Apr-07 20:53
memberValeri18-Apr-07 20:53 
GeneralGood job Pin
joachimF, 7-Dec-06 0:52
memberjoachimF7-Dec-06 0:52 
QuestionHow can we unzip password-protected files. Pin
Anjum Rizwi, 26-Nov-06 20:56
memberAnjum Rizwi26-Nov-06 20:56 
QuestionIs it possible to read in the middle of the zip file? Pin
shultas, 30-Aug-06 16:52
membershultas30-Aug-06 16:52 
AnswerRe: Is it possible to read in the middle of the zip file? Pin
Valeri, 30-Aug-06 21:21
memberValeri30-Aug-06 21:21 
GeneralRe: Is it possible to read in the middle of the zip file? Pin
shultas, 31-Aug-06 12:19
membershultas31-Aug-06 12:19 
GeneralZip Folder qithin a zip folder Pin
M Ali Raza, 5-Apr-06 22:02
memberM Ali Raza5-Apr-06 22:02 
GeneralProblem In Latin FileNames Pin
dealarconjose, 15-Mar-06 2:03
memberdealarconjose15-Mar-06 2:03 
GeneralAlternative (with code) Pin
Elmue, 21-Nov-05 1:41
memberElmue21-Nov-05 1:41 
GeneralWhat about multiple folders? Pin
dragomir, 22-Dec-05 1:54
memberdragomir22-Dec-05 1:54 
GeneralRe: What about multiple folders? Pin
Elmue, 31-Dec-05 2:53
memberElmue31-Dec-05 2:53 
GeneralRe: What about multiple folders? Pin
wyattda, 17-Jan-06 18:36
memberwyattda17-Jan-06 18:36 

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