internal ZlibZipReader(string path)
        {
            string resolvedPath = ZipLib.ResolvePath(path);

            if (!File.Exists(resolvedPath))
            {
                throw new FileNotFoundException("File does not exist:" + path);
            }
            this.handle = ZipLib.unzOpen(resolvedPath);
            if (handle == IntPtr.Zero)
            {
                throw new ZipException("Unable to open ZIP file:" + path);
            }
        }
        public override void ExtractOfficeDocument(string zipFileName, string directory)
        {
            IntPtr       zhandle = ZipLib.unzOpen(zipFileName);
            FileStream   fs      = new FileStream(zipFileName, FileMode.Open, FileAccess.Read);
            BinaryReader br      = new BinaryReader(fs);
            int          i       = 0;
            int          flag    = 0;
            int          flag2   = 0;
            int          count   = 1;

            try
            {
                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    if (br.ReadByte() == 0x50)
                    {
                        if (br.ReadByte() == 0x4b)
                        {
                            if (br.ReadByte() == 0x03)
                            {
                                if (br.ReadByte() == 0x04)
                                {
                                    br.BaseStream.Position += 22;
                                    int filenameLength = br.ReadInt16();
                                    br.BaseStream.Position += 2;
                                    byte[] buffer = new byte[filenameLength];
                                    br.BaseStream.Read(buffer, 0, filenameLength);
                                    br.BaseStream.Position -= (26 + filenameLength);
                                    string        fullFileName = directory + ZipLib.ResolvePath(Encoding.GetEncoding("UTF-8").GetString(buffer));
                                    DirectoryInfo dir          = new DirectoryInfo(fullFileName);
                                    if (fullFileName.Contains("/"))
                                    {
                                        string tempdir = "";
                                        while (tempdir != dir.Root.FullName)
                                        {
                                            tempdir = dir.Parent.FullName;
                                            dir     = new DirectoryInfo(dir.Parent.FullName);
                                            if (!Directory.Exists(tempdir))
                                            {
                                                Directory.CreateDirectory(tempdir);
                                            }
                                        }
                                    }

                                    FileStream writeFile = File.Create(fullFileName);
                                    if (i < count)
                                    {
                                        try
                                        {
                                            i++;
                                            if (flag == 0)
                                            {
                                                ZipLib.unzGoToFirstFile(zhandle);
                                                flag = 1;
                                            }
                                            else
                                            {
                                                int fir = ZipLib.unzGoToNextFile(zhandle);
                                            }
                                            ZipEntryInfo zipentryInfo;
                                            ZipLib.unzGetCurrentFileInfo(zhandle, out zipentryInfo, null, 0, null, 0, null, 0);
                                            ZipLib.unzOpenCurrentFile(zhandle);
                                            ZipFileInfo zipfileinfo;
                                            ZipLib.unzGetGlobalInfo(zhandle, out zipfileinfo);
                                            if (flag2 == 0)
                                            {
                                                count = (int)zipfileinfo.EntryCount;
                                                flag2 = 1;
                                            }
                                            byte[] buffer2 = new byte[zipentryInfo.UncompressedSize];
                                            ZipLib.unzReadCurrentFile(zhandle, buffer2, (uint)zipentryInfo.UncompressedSize);
                                            writeFile.Write(buffer2, 0, (int)zipentryInfo.UncompressedSize);
                                            br.BaseStream.Position += zipentryInfo.CompressedSize;
                                        }
                                        catch (Exception ex)
                                        {
                                            throw ex;
                                        }
                                        finally
                                        {
                                            if (writeFile != null)
                                            {
                                                writeFile.Close();
                                            }
                                            if (ZipLib.unzCloseCurrentFile(zhandle) != 0)
                                            {
                                                ZipLib.unzCloseCurrentFile(zhandle);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
                if (br != null)
                {
                    br.Close();
                }
            }
        }