I have written code that doesnt throw any errors but it somehow srews up the file so i cant open it. Anyway if someone has done this before and have code please share it with me.
This is what i got so far maybe someone knows whats wrong with it:
Public Sub UnzipFirstFileSharpZipLibInMemory(ByVal BytesOfArchive() As Byte, ByVal PathOfFile As String)
Dim msZipInputStream As New MemoryStream(BytesOfArchive) ';'
Dim s As ZipInputStream = New ZipInputStream(msZipInputStream)
Dim theEntry As ZipEntry
Dim blnFirstFileInArchive As Boolean = True
While True
theEntry = s.GetNextEntry
If theEntry Is Nothing Or blnFirstFileInArchive = False Then
Exit While
Else
blnFirstFileInArchive = False
End If
Dim fileName As String = Path.GetFileName(theEntry.Name)
If Not fileName = String.Empty Then
Dim streamWriter As New MemoryStream
Dim size As Integer = 2048
Dim data(2048) As Byte
While True
size = s.Read(data, 0, data.Length)
If size > 0 Then
streamWriter.Write(data, 0, size)
Else
Exit While
End If
End While
Dim bytFile(streamWriter.Length - 1) As Byte
streamWriter.Read(bytFile, 0, streamWriter.Length)
My.Computer.FileSystem.WriteAllBytes(PathOfFile, bytFile, False)
streamWriter.Close()
End If
End While
s.Close()