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