class Program
{
static void Main(string[] args)
{
ZipFile.CreateFromDirectory(@"E:\AA", @"E:\BB.zip");
ZipFile.ExtractToDirectory(@"E:\BB.zip", @"E:\CC");
Console.Read();
}
private static void Compress()
{
FileStream fs = new FileStream(@"e:\AA.txt", FileMode.Open);
FileStream ds = new FileStream(@"e:\BB.dat", FileMode.Create);
GZipStream g = new GZipStream(ds, CompressionMode.Compress);
byte[] buffers = new byte[1024];
int count = fs.Read(buffers, 0, 1024);
while (count>0)
{
g.Write(buffers, 0, count);
count = fs.Read(buffers, 0, 1024);
}
g.Close();
fs.Close();
ds.Close();
Console.Read();
}
private static void Decompress()
{
FileStream fs = new FileStream(@"e:\BB.dat", FileMode.Open);
FileStream ds = new FileStream(@"e:\CC.txt", FileMode.Create);
GZipStream g = new GZipStream(fs, CompressionMode.Decompress);
byte[] buffers = new byte[1024];
int count = g.Read(buffers, 0, 1024);
while (count > 0)
{
ds.Write(buffers, 0, count);
count = g.Read(buffers, 0, 1024);
}
g.Close();
fs.Close();
ds.Close();
Console.Read();
}
}