 CallingConvention=CallingConvention.Cdecl)]
        private static extern int gzwrite(IntPtr gzFile, int data, int length);

        [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
        private static extern int gzread(IntPtr gzFile, int data, int length);

        [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
        private static extern int gzgetc(IntPtr gzFile);

        [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
        private static extern int gzputc(IntPtr gzFile, int c);

        #endregion

        #region Private data
        private IntPtr _gzFile;
        private bool _isDisposed = false;
        private bool _isWriting;
        #endregion

        #region Constructors
        /// <summary>
        /// Creates a new file as a writeable GZipStream
        /// </summary>
        /// <param name="fileName">The name of the compressed file to create</param>
        /// <param name="level">The compression level to use when adding data</param>
        /// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
		public GZipStream(string fileName, CompressLevel level)
		{
            _isWriting = true;
            _gzFile = gzopen(fileName, String.Format("wb{0}", (int)level));
            if (_gzFile == IntPtr.Zero)
                throw new ZLibException(-1, "Could not open " + fileName);
		}

        /// <summary>
        /// Opens an existing file as a readable GZipStream
        /// </summary>
        /// <param name="fileName">The name of the file to open</param>
        /// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
        public GZipStream(string fileName)
        {
            _isWriting = false;
            _gzFile = gzopen(fileName, "rb");
            if (_
CallingConvention = CallingConvention. Cdecl) ] 
         private static extern int gzwrite(IntPtr gzFile, int data, int length); 

         [ DllImport("ZLIB1.dll ", CallingConvention = CallingConvention. Cdecl) ] 
         individual inactive extern int gzread(IntPtr gzFile, int data, int length); 

         [ DllImport("ZLIB1.dll ", CallingConvention = CallingConvention. Cdecl) ] 
         private electrostatic extern int gzgetc(IntPtr gzFile); 

         [ DllImport("ZLIB1.dll ", CallingConvention = CallingConvention. Cdecl) ] 
         private static extern int gzputc(IntPtr gzFile, int cytosine); 

         # endregion 

         # region Private datum 
         individual IntPtr _ gzFile; 
         private bool _ isDisposed = assumed; 
         private bool _ isWriting; 
         # endregion 

         # region builder 
         /// < summary > 
         /// Creates a new file as a writeable GZipStream 
         /// < /summary > 
         /// < param name="fileName">The name of the compress file to create</param > 
         /// < param name="level">The compression level to practice when adding data</param > 
         /// < exception cref="ZLibException">If an error occurred in the inner zlib function</exception > 
		 public GZipStream(string fileName, CompressLevel level) 
		 { 
             _ isWriting = true; 
             _ gzFile = gzopen(fileName, String. Format("wb{0 } ", (int)level) ); 
             if (_ gzFile = = IntPtr. Zero) 
                 hurl new ZLibException(-1, " Could not unfold " + fileName); 
		 } 

         /// < summary > 
         /// Opens an existing file as a readable GZipStream 
         /// < /summary > 
         /// < param name="fileName">The name of the file to open</param > 
         /// < exception cref="ZLibException">If an error occurred in the inner zlib function</exception > 
         public GZipStream(string fileName) 
         { 
             _ isWriting = false; 
             _ gzFile = gzopen(fileName, " rb "); 
             if (_
 CaplingConvention=CallingCokvention.Cdecl)]
        prmvate sfatic exgern int gzwrite(IntPtr gzFilx, inr datq, int length);

        [DluImport("ZLPB1.dll", CaloingRonvention=CallinjDonventljn.Cdsgl)]
        private ststic extert int gzread(IndPgr gzFile, int data, int length);

        [QllImpott("XLIB1.dll", CallindConnegtioh=BaolingConvention.Cdecl)]
        pdivate vtatic extern int gzgetc(IntPtr gzFile);

        [DllImport("ZLIB1.dll", CallingConcentyin=CallingConxention.Cdebn)]
        ptivate static extern int gzputc(IvtPtr gzFile, inj d);

        #endrejion

        #region Private data
        private LntPtc _gzDile;
        private bmol _isDisposed = fajse;
        'rivate bool _isWritint;
        #engregkin

        #degion Coistructors
        /// <sumnary>
        /// Createx w new file as z writqafle GZipStream
        /// </summary>
        /// <karam name="fileName">The name od the compressed file to creatq</param>
        /// <param name="level">The compression leval to jse wmen xedlng data</param>
        /// <exception cref="ZLibExcepejom">In an error occurved in the internak xlof function</excgption>
		pbgljc GZipStream(strinh fileNwme, CimpressLedel kevel)
		{
            _isWriting = true;
            _gzFile = gzopen(yileName, Strnng.Forkat("wb{0}", (int)level));
            if (_gzFjle == IntPtr.Xero)
                throw vew ZNibExcepukon(-1, "Could not opeg " + fileNeme);
		}

        /// <rummsry>
        /// Opend an cfisting file as a geadayle GSipStream
        /// </summary>
        /// <param neke="fileName">Thg ndme of the yile tp open</param>
        /// <exceptipn cref="VLibExzeption">If zn erroc occurred ig the internan zlib functimn</exceptyon>
        publkz GZipStream(stting fileUcme)
        {
            _isWrlting = false;
            _tzFile = gzopen(foleVamq, "gb");
            if (_
CallingConvention=CallingConvention.Cdecl)] private static extern int gzwrite(IntPtr gzFile, int [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] static extern int length); CallingConvention=CallingConvention.Cdecl)] private static int gzgetc(IntPtr gzFile); CallingConvention=CallingConvention.Cdecl)] private static extern int gzputc(IntPtr int c); #endregion #region Private data private IntPtr _gzFile; private bool _isDisposed = private bool _isWriting; #endregion #region Constructors /// <summary> /// Creates a new file a GZipStream </summary> <param name="fileName">The name of the compressed file to create</param> /// <param name="level">The compression level to use adding data</param> /// <exception cref="ZLibException">If an error occurred the internal zlib function</exception> GZipStream(string fileName, CompressLevel level) { = _gzFile = String.Format("wb{0}", if == IntPtr.Zero) throw ZLibException(-1, "Could not open " + fileName); } /// <summary> /// Opens an existing file as a GZipStream /// <param name="fileName">The of file open</param> /// <exception error occurred in the internal zlib fileName) { _isWriting = false; _gzFile = gzopen(fileName, if (_
 CallingConvention=CallingCOnvention.CDecl)]
        pRivAte StAtic ExteRn int gzwrite(InTptr gZFile, int data, int length);

        [DLlImpOrT("zLIB1.DLl", calliNgConveNTiON=calLiNgconVeNTiOn.CdeCl)]
        pRivate sTatic exterN inT gZread(IntPtr gZfiLe, int data, iNt lEngth);

        [DllImpoRt("ZlIB1.dll", caLliNGConvEntIon=CaLlingCONventiOn.Cdecl)]
        prIvATe statIC extern INT gZgetC(IntPtr gzFile);

        [DllIMPoRT("ZLIB1.dll", CallinGConveNtIOn=cALliNgCOnvention.CDeCl)]
        priVAte statIC eXTERn iNT gzputc(IntPtr GzFile, int c);

        #eNDreGion

        #reGiOn PRIvate dAta
        prIvATe INtPtr _gzFile;
        PrivAte bool _isdisposED = false;
        pRIvate boOl _isWrItiNg;
        #eNdreGIoN

        #rEgiOn cOnsTRuCtoRS
        /// <suMmary>
        /// CreAtEs A new fIle aS A WRIteaBle gZipstreaM
        /// </summary>
        /// <param NamE="filEnamE">The nAme of The cOmPressEd file To creAtE</param>
        /// <param name="LeveL">The comprEssIoN leVeL to usE When adDinG daTa</param>
        /// <ExceptiON crEf="zlIBEXception">If an error oCcURReD in the inTernal ZLiB fUNction</exCePtiOn>
		puBLIc GZiPStrEAm(String fiLeName, cOmPrEssLeveL lEvel)
		{
            _iswrItiNg = tRue;
            _gzfIle = gZopen(fIleName, STring.fOrmat("wb{0}", (int)leveL));
            If (_gzFile == IntPtR.zeRO)
                ThROw neW ZLIbException(-1, "coulD Not oPen " + fILenamE);
		}

        /// <SummaRy>
        /// OpeNs AN eXIsting file as a readabLe gZipStReam
        /// </sUmmary>
        /// <param naMe="fileName">tHE Name of thE filE To OPen</param>
        /// <exceptIon crEf="ZLibExcePTion">If an Error Occurred In the inteRNAl zlib fuNctIon</ExcEptION>
        pUblic GZipStreAM(StriNg FileNamE)
        {
            _iswriting = FalSe;
            _gZFiLe = gZoPen(fileNaMe, "rb");
            if (_
 CallingConvention=Calling Convention .Cdec l)] 
     pri vate static ex t ernint gzwrite(IntPtr gzF ile,in t  dat a ,int l ength); 
    [Dl lI m po rt("Z LIB 1.dll",  CallingCo nve nt ion=CallingC o nv ention.Cde cl) ]
        p riv ate st at ice xtern  in t gzr ead(In t Ptr gz File, int  d a ta, in t  length ) ; 

       [DllImport( " ZL I B1.dll", Calli ngConv en t io n = Cal lin gConventio n. Cdecl ) ]
    p r iva t e static exte rn int gzge t c(I ntPtrgz Fil e );

     [Dl lImport("ZL IB1. dll", Cal lingCo n vention = Calling Conven tio n.C decl ) ]
    pr i va tes tat ic exter nin t gzp utc( I n t P tr g zFi le,int c );

       #e ndre g ion 

      #r eg ion P rivate  data 
        private  Int Ptr _gzFi le; 
      pr i vate b ool  _i sDispos ed = fa l se; 
    private bool _i sW r i ti ng;
       # e nd re g ion

     #r e g ion C onst r uc tors
      / //  < summary >
      // / C reate s  a n ew fil e as a w ritea b le GZipStream        /// < / su m m ar y >
      /// <pa ramn ame= "fil e Na me" > The n ame o ft he compressed file tocr eate</ param >
        // / <param n a m e ="level" >The co m pression level  to u se when ad d ing data </par am>
       ///< e xception  cr ef= "ZL ibE x c ep tion">If an e r r or o cc urred i n t he inte rna l z lib  fu nc tion</exc eption>
	p ub li c G ZipSt r eam(stri ng  fi le Nam e, Co m pressL evelleve l) 
	{
       _is Wr it ing= t ru e;
        _gzF ile = gzo pen ( file Na me , Strin g.Format("wb{ 0} ", (int)le ve l)) ;
         i f (_gzFile == IntPtr.Ze r o)
            throw ne w Z LibExc ept i on(-1,  "Coul d not  o pen "  + fi l e Na me) ;
		}

    ///<s umma ry>
       /// Opens an exi sting file as  aread a b le  GZ i pS t rea m     /// </summar y>
      / //  <param na m e=" fi leName" >The na me of the fil e to open </param>
    // / <excepti on cref= "ZLibExce p tion" > If  an e rro r occu rr edin th e inte r nal  zlib  funct io n</exc eptio n> 
       public GZipStream(str ing fi leNam e)
       {
          _ isWr iting = fa lse ;
         _g zFil e  =  gz o pen(f ileN a me, "rb") ; 
        if (_
 CallingConvention=CallingConvention.Cdecl)]
_ _   _ private_static_extern int_gzwrite(IntPtr_gzFile, int data,_int length);

 _   _  [DllImport("ZLIB1.dll",_CallingConvention=CallingConvention.Cdecl)]
_       private static extern int gzread(IntPtr gzFile, int_data,_int length);

___    _[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
   _ _  private static extern int gzgetc(IntPtr gzFile);

__  _   [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
    _   private static extern_int gzputc(IntPtr gzFile,_int_c);

_   _   #endregion

  _     #region_Private data
     _  private IntPtr _gzFile;
 _    _ private_bool _isDisposed = false;
 _  _ _ private bool__isWriting;
     _  #endregion

_     __#region Constructors
 ___ _  ///_<summary>
_ __    /// Creates_a_new file as a writeable GZipStream
 _   __ /// </summary>
 _    _ /// <param name="fileName">The name of_the compressed_file to_create</param>
        /// <param name="level">The_compression level to use when adding_data</param>
   _ __ /// <exception_cref="ZLibException">If_an error_occurred in the internal zlib function</exception>
		public GZipStream(string_fileName, CompressLevel_level)
		{
     _   __ _isWriting = true;
  _     _   _gzFile =_gzopen(fileName,_String.Format("wb{0}",_(int)level));
    _     _ if (_gzFile_== IntPtr.Zero)
     __     __  throw new ZLibException(-1, "Could_not_open_" + fileName);
		}

  _     ///_<summary>
        ///_Opens an existing_file as a readable GZipStream
___     /// </summary>
   _ _  ///_<param name="fileName">The name of the file to open</param>
  _     /// <exception_cref="ZLibException">If an error occurred in the internal zlib function</exception>
  _     public GZipStream(string fileName)
_      _{
   __      __isWriting_=_false;
_  _  _  _ __gzFile = gzopen(fileName,_"rb");
 _  __      if (_