Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20551 |

    Hi All,

    I am using  Using Xceed Zip v5.6 to a big Archive, several GB, with many new additions and removal. Ok Using batch Update the library rewrite archive only once but How can update the archive without fully rewritting it?

    Thanks

    Luca

    Imported from legacy forums. Posted by Luca (had 514 views)

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Luca,

    Only certain update operations can avoid a full rewriting.

    If you are adding new files to an existing archive, they will be added at the end of the archive and only the archive index will be updated.

    However, if you are replacing an existing file in the archive or deleting a file in the archive, those updates cannot be made in-place and require the use of temp files. The archive file has to be rebuilt in these cases.

    For example:

       static void F34605()
       {
          AbstractFile zipFile = new DiskFile( @”D:\Support\F34605\F34605.zip” );

          // If the zip file already exists, delete it
          if( zipFile.Exists )
             zipFile.Delete();

          ZipArchive zip = new ZipArchive( zipFile );
          zip.TempFolder = new DiskFolder( @”D:\Support\F34605″ );

          AbstractFile file;

          // Because we are creating a new zip file, this update will be created in-place
          using( new AutoBatchUpdate( zip ) )
          {
             file = new DiskFile( @”D:\Support\Xceed.Zip.Tests\Data\20070702_195208_RED.xml” );
             file.CopyTo( zip, true );

             file = new DiskFile( @”D:\Support\Xceed.Zip.Tests\Data\tvDebug.log” );
             file.CopyTo( zip, true );
          }

          // Here we are adding a *new* file to the archive.
          // The file will be added at the end of the archive so the update so the
          // update will be made in-place.
          using( new AutoBatchUpdate( zip ) )
          {
             file = new DiskFile( @”D:\Support\Xceed.Zip.Tests\Data\PAT021.BMP” );
             file.CopyTo( zip, true );
          }

          // Here, we are *replacing* an existing file in the archive. This operation
          // cannot be made in-place so a temp file will be used and the archive
          // file will be rewritten.
          using( new AutoBatchUpdate( zip ) )
          {
             file = new DiskFile( @”D:\Support\Xceed.Zip.Tests\Data\PAT021.BMP” );

             AbstractFile zippedFile = zip.GetFile( “20070702_195208_RED.xml” );
             file.CopyTo( zippedFile, true );
          }

          // Here, we are *deleting* an existing file in the archive. This operation
          // cannot be made in-place so a temp file will be used and the archive
          // file will be rewritten.
          using( new AutoBatchUpdate( zip ) )
          {
             AbstractFile zippedFile = zip.GetFile( “20070702_195208_RED.xml” );

             if( zippedFile.Exists )
             {
                zippedFile.Delete();
             }
          }
       }

    Imported from legacy forums. Posted by Diane [Xceed] (had 764 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.