\\首先贴出加压压缩文件的类,代码中会有详细的介绍
public void UnZip(string[] args) // 参数是一个数组,可以有两个元素分别表示‘待解压的文件’和‘解压后放置的目标目录’
{
ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
string directoryName = Path.GetDirectoryName(args[1]);
string fileName = Path.GetFileName(theEntry.Name);
//生成解压目录
Directory.CreateDirectory(directoryName);
if (fileName != String.Empty)
{
//解压文件到指定的目录
FileStream streamWriter = File.Create(args[1]+theEntry.Name);
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = s.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
s.Close();
}
-------------------------------------------------------
//调用方法
#region (2)解压文件到本地文件夹
string[] FileProperties = new string[2];
FileProperties[0] = @"d:\客户端\22.zip";//待解压的文件
FileProperties[1] = @"d:\客户端\";//解压后放置的目标目录
UnZipClass UnZc = new UnZipClass();
UnZc.UnZip(FileProperties);
#endregion
------------------------------------------------------------
这样就可以达到解压文件的目的了