Welcome to the Xceed Community | Help
Community Search  
More Search Options

Read a zip file from byte array

Sort Posts: Previous Next
  •  07-02-2009, 5:11 PM Post no. 22235

    Read a zip file from byte array

    Hi,

    I have created a zip file and converted it to a byte array to be sent across to another component. In that component, I have to read it back from byte array and convert it to either a zip file or extract contents of the zip file to a local folder. How can i read the zip file from the byte array. Please help with a code snippet.

    Thanks.

     

    Private Shared Function ZipSelectedFiles(ByVal list As Dictionary(Of Integer, String)) As Byte()

    Dim file As DiskFile

    Dim memFile As New MemoryFile("RAM_File", "lasfiles.zip")

    Dim zip As New ZipArchive(memFile)

    Dim zipBytes() As Byte

    For Each kvp As KeyValuePair(Of Integer, String) In list

    file = New DiskFile(kvp.Value)

    file.CopyTo(zip, False)

    Next kvp

    Dim zipMemStream As New MemoryStream()

    Dim s As Stream = memFile.OpenRead()

    Dim buffer(1024) As Byte

    Dim bytesRead As Integer

    Do

    bytesRead = s.Read(buffer, 0, buffer.Length)

    If bytesRead > 0 Then

    zipMemStream.Write(buffer, 0, bytesRead)

    End If

    Loop Until bytesRead = 0

    s.Close()

    zipBytes = zipMemStream.ToArray()

    zipMemStream.Close()

    Return zipBytes

    End Function

  •  02-21-2010, 5:05 PM Post no. 25880 in reply to 22235

    Re: Read a zip file from byte array

    I need an answer to this question
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.