XceedZip load contents of zip file into byte array VB.NET

Posted on 2007-07-25
Last Modified: 2012-05-05
I am trying to load a file out of a zip file into a byte array. This seems to be working correctly, however it only ever seems to populate the array with the compressed version of the file, not the entire file.

Im guessing that this is because it is not being unzipped? However I can not for the life of me work out how to do this?

Here is the code that I am currently using...

        Dim DF As New DiskFile(SomeFileName)
        Dim zip As New ZipArchive(DF)
        Dim folder As New MemoryFolder("RAM_DISK", "folder")
        zip.CopyFilesTo(folder, True, True)

        Dim files() As AbstractFile = zip.GetFiles(True, "*.*")
        Dim file As AbstractFile

        Dim S1 As Stream
        Dim oReceivedFile as byte()

        For Each file in files  
                        S1 = file.OpenRead
                        oReceivedPDFFile = New Byte(S1.Length) {}
                        S1.Read(oReceivedFile, 0, S1.Length)

oReceivedFile only ever seems to have the unzipped file in it...

any help would be fantastic.

Question by:MTSDL
    LVL 19

    Accepted Solution

    The docs for XceedZip are not very enlightening, but I notice that you unzip the archive into a MemoryFolder but call GetFiles on the original archive (zip.GetFiles(True, "*.*")).  Try calling GetFiles in the MemoryFolder instead (folder.GetFiles(True, "*.*")).

    Author Comment

    Thanks alot dricahrds... that worked a treat :-)

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now