需要说明一下,这需要调用一个解压缩类库。。 ICSharpCode.SharpZipLib.dll using System; using System.IO; using System.Collections.Generic; using System.Text; using ICSharpCode.SharpZipLib.Zip; namespace ZipLib { /// <summary> /// 解压缩类 /// </summary> public static class ZIP { /// <summary> /// 解压ZIP文件包 /// </summary> /// <param name="strZipFile">ZIP文件路径</param> /// <param name="strDir">解压后的文件目录路径</param> /// <returns>是否解压成功</returns> public static bool unzipFiles(string strZipFile, string strDir) { //判断ZIP文件是否存在 if (File.Exists(strZipFile)) { //判断目录是否存在 bool bUnzipDir = false; //判断是否需要创建目录 if (!Directory.Exists(strDir)) bUnzipDir = (Directory.CreateDirectory(strDir) != null); else bUnzipDir = true; //如果解压目录存在 if (bUnzipDir) { //获得ZIP数据流 ZipInputStream zipStream = new ZipInputStream(File.OpenRead(strZipFile)); if (zipStream != null) { ZipEntry zipEntry = null; while ((zipEntry = zipStream.GetNextEntry()) != null) { string strUnzipFile = strDir + "//" + zipEntry.Name; string strFileName = Path.GetFileName(strUnzipFile); string strDirName = Path.GetDirectoryName(strUnzipFile); //是否为解压目录 if (!string.IsNullOrEmpty(strDirName)) Directory.CreateDirectory(strDirName); //是否为解压文件 if (!string.IsNullOrEmpty(strFileName)) { //解压文件 FileStream unzipFileStream = new FileStream(strUnzipFile, FileMode.Create); if (unzipFileStream != null) { byte[] buf = new byte[2048]; int size = 0; while ((size = zipStream.Read(buf, 0, 2048)) > 0) unzipFileStream.Write(buf, 0, size); //关闭Stream unzipFileStream.Flush(); unzipFileStream.Close(); } } } //关闭ZIP流 zipStream.Close(); //返回值 return true; } } } return false; } } }