473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to compress and decompress folder

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/down.zip")))
{
s.SetLevel(9);
byte[] buffer = new byte[4096];
foreach (string file in filenames)
{
ZipEntry entry = new ZipEntry(Path.GetFileName(file));
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(file))
{
int sourceBytes;
do
{
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
}
while (sourceBytes > 0);
}
}
s.Finish();
s.Close();
But I can not decompress the zip file.
Could some one help me? Thanks in advance.
Minh Chieu
Jul 4 '07 #1
0 1466

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

Similar topics

1
by: Herbert Wildmeister via .NET 247 | last post by:
Does anybody know a way to compress and decompress AVI videofiles in C# .NET using all installed video codecs? I've foundthe Video Compression Manager and a class wrapper for C++ but noCLS compliant...
1
by: Tim Bücker | last post by:
Hello. I am working on a program that generates about 1000 pictures that should reside in an avi later. Of course this amount of pictures creates a very huge avi-file but my main problem is...
1
by: Marc Jennings | last post by:
Hi there, I have a problem in that I need to de-compress a file that was compressed using the UNIX compress command. The resulting filename is helloworld.xml.Z I have looked at SharpZipLib,...
8
by: Jose L. Velazquez | last post by:
Hi all, I have made a webservice that returns an XML, but sometimes the connection is so slow and there is a lot of data to be returned. I would like to know if it is possible to send this data...
1
by: Szeged | last post by:
I'm new to JavaScript. I have relatively large amounts of text (~200 kB) that I need to transfer to my web application every now and then. Using RAR, I get a 5:1 compression ratio on these files,...
1
by: Evgeny.Br | last post by:
Hi All, I use .NET 2.0. I experience huge performance problem retrieving dataset from web service. The dataset volume returned from WS is about 5-7 megabyte, it's take too long.
6
by: Adriano | last post by:
Can anyone recommend a simple way to compress/decomress a String in .NET 1.1 ? I have a random string of 70 characters, the output from a DES3 encryption, and I wish to reduce the lengh of it, ...
1
by: Carly | last post by:
Hello, I am just wondering if somebody can look on this piece of code and let me know what is wrong with DECOMPRESSION. Dim mystr As String = "flower power" 'deflate Dim mybytearray() As...
0
by: vampire1986 | last post by:
Hi all. I have project compress file using C#. I'm using name space IO.Compression and i saw this code on Internet but it is compress to file bigger than source file. Can you help me, please.Thanks...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.