日期:2014-05-18  浏览次数:20850 次

解压问题求解?
作者:海色珊瑚   2006-12-09   17:05:14  
标签:    
   

namespace   Ehai.FileUnzip

{

        public   class   Unzip

        {

                public   void   UnzipFiles(string   SourceZip,   string   DesPath,bool   cover)

                {

                        ZipInputStream   stream   =   new   ZipInputStream(File.OpenRead(SourceZip));

                        ZipEntry   theEntry;

                        if   (!Directory.Exists(DesPath))   Directory.CreateDirectory(DesPath);

                          if   (DesPath[DesPath.Length   -   1]   !=   Path.DirectorySeparatorChar

                                  DesPath   +=   Path.DirectorySeparatorChar;

                        while   ((theEntry   =   stream.GetNextEntry())   !=   null)

                        {

                                string   directoryName   =   Path.GetDirectoryName(theEntry.Name);

                                string   fileName   =   Path.GetFileName(theEntry.Name);

                                //生成解压目录

                                //Directory.CreateDirectory(directoryName);

                                if   (directoryName   !=   String.Empty)

                                {

                                        if   (Directory.Exists(DesPath   +   directoryName)   &&   cover   ==   false)

                                        {

                                                throw   new   Exception( "该文件已存在不能覆盖! ");   return;

                                        }