解压ZIP文件的方法如下:(内容为自己实际项目下的一个更新程序)
string strZipPath = System.Windows.Forms.Application.StartupPath + "//Update.zip"; //需要解压的文件
string strUnZipPath = System.Windows.Forms.Application.StartupPath; //解压的路径
bool overWrite = true;//设置是否覆盖文件
ReadOptions options = new ReadOptions();
options.Encoding = Encoding.Default;//设置编码,解决解压文件时中文乱码
using (ZipFile zip = ZipFile.Read(strZipPath, options))
{
foreach (ZipEntry entry in zip)
{
if (string.IsNullOrEmpty(strUnZipPath))
{
strUnZipPath = strZipPath.Split('.')[0];
}
if (overWrite)
{
entry.Extract(strUnZipPath, ExtractExistingFileAction.OverwriteSilently);//解压文件,如果已存在就覆盖
}
else
{
entry.Extract(strUnZipPath, ExtractExistingFileAction.DoNotOverwrite);//解压文件,如果已存在不覆盖
}
}