By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,798 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

How to compress and decompress folder

P: 2
Hi all,
I'm a new with SharpZipLib. I want to zip a folder which has some files and subfolders, and unzip it to a new folder with the same structure. Now i can zip the folder. This is my code.
// Zip up the files
string[] filenames = Directory.GetFiles("C:/Down");
using (ZipOutputStream s = new ZipOutputStream(File.Create("C:/ZipFile/")))
byte[] buffer = new byte[4096];
foreach (string file in filenames)
ZipEntry entry = new ZipEntry(Path.GetFileName(file));
entry.DateTime = DateTime.Now;
using (FileStream fs = File.OpenRead(file))
int sourceBytes;
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
while (sourceBytes > 0);
But I can not decompress the zip file.
Could some one help me? Thanks in advance.
Minh Chieu
Jul 4 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.