Adding files to an existing Zip

Jul 14, 2009 at 7:26 PM

Hello,

I need to do what I believe is a common task but have found no discussion of the technique.  An unattended program runs each night and add certain files to an existing Zip archive.  I've fiddled around and come up with the technique below.  However, I'm concerned it may not be the best way to do it, particularly as the Zip gets large. 

Is the example below reasonable?   Thanks in advance!

 

Using zip As ZipFile = ZipFile.Read(sArchivePath)
         Try
            zip.UpdateFile(sFilePath)
            zip.Save(sArchivePath)
         Catch ex As Exception

        ' Error handler

         End Try

End Using

 

Coordinator
Jul 14, 2009 at 9:51 PM

If you are adding a single file, that is the correct way to do it!

If you like, you can omit the sArchivePath in the Save(). 

  Using zip As ZipFile = ZipFile.Read(sArchivePath)
        Try
            zip.UpdateFile(sFilePath)
            zip.Save()
        Catch ex As Exception
        ' Error handler
        End Try
  End Using

How large is the zip file? Are you experiencing any real problems, or only doubts?