Пример #1
0
        public override void AddEntry(string relativePath, CompressionMethod compressionMethod)
        {
            string           resolvedPath = ZipLib.ResolvePath(relativePath);
            ZipFileEntryInfo info;

            info.DateTime = DateTime.Now;

            if (this.entryOpened)
            {
                ZipLib.zipCloseFileInZip(this.handle);
                this.entryOpened = false;
            }

            int result = ZipLib.zipOpenNewFileInZip(this.handle, resolvedPath, out info, null, 0, null, 0, String.Empty, (int)compressionMethod, (int)CompressionLevel.Default);

            if (result < 0)
            {
                throw new ZipException("Error while opening entry for writing: " + relativePath + " - Errorcode: " + result);
            }
            this.entryOpened = true;
        }
Пример #2
0
 public override void Close()
 {
     if (handle != IntPtr.Zero)
     {
         int result;
         if (this.entryOpened)
         {
             result = ZipLib.zipCloseFileInZip(this.handle);
             if (result != 0)
             {
                 throw new ZipException("Error while closing entry - Errorcode: " + result);
             }
             this.entryOpened = false;
         }
         result = ZipLib.zipClose(this.handle, "");
         handle = IntPtr.Zero;
         // Should we raise this exception ?
         if (result != 0)
         {
             throw new ZipException("Error while closing ZIP file - Errorcode: " + result);
         }
     }
 }