Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Zipping multiple files dynamically

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

    I want to add more than 1 file to my ziparchive. Here is what I have. Each time i is incremented, it source will be set to a new file.

    How exactly would I do this? If i > 0  I tried saying source = source + New DiskFile(m_fileList(i)) but that didn’t work. Please advise. Thanks

    ‘ Zip each file

    Dim source As AbstractFile

    For i = 0 To m_fileCnt – 1

    source =

    New DiskFile(m_fileList(i))

    Next

    Imported from legacy forums. Posted by Richard (had 1076 views)

    User (Old forums)
    Member
    Post count: 23064

    Well I figured this out. In case anyone else stumbles upon my question, here is the solution in vb.net. Could easily be done in c# too.

    ‘ The archive does not exist, so now create a new zip file

    Dim archive As New ZipArchive(zipFile)

    For i = 0 To m_fileCnt – 1

    Dim file(i) As AbstractFile ‘ Declare file of type AbstractFile

    file(i) =

    New DiskFile(m_fileList(i)) ‘ file(i) will be the current file

    ‘ Begin Compression

    archive.BeginUpdate()

    ‘ Prevent archive from being modified until EndUpdate() is called

    archive.DefaultCompressionMethod = CompressionMethod.Deflated

    ‘ Algorithm used by PKZip 2.04g

    archive.DefaultEncryptionMethod = EncryptionMethod.WinZipAes

    ‘ 2 choices. This is the strongest

    archive.DefaultEncryptionPassword = m_Password

    ‘ setup previously

    file(i).CopyTo(archive,

    True) ‘ Copy current file to archive

    archive.EndUpdate()

    ‘ EndUpdate() – archive can now be modified again

    Next

     

    Imported from legacy forums. Posted by Richard (had 1449 views)

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