'Unzipping error - Unexpected end - Using ZipArchive

I got the following Code:

  Dim ms = New MemoryStream()
  CustomReportVorlage.ExportToPdf(ms) 
  Dim bt2 = ms.ToArray()
  Dim outStream = New MemoryStream() 
  Dim archive = new ZipArchive(outStream, ZipArchiveMode.Create, False)  
  Dim fileInArchive = archive.CreateEntry(String.Concat(String.Concat("Zugangsdaten_",src(0)("KURZBEZEICHNUNG")), ".pdf"), CompressionLevel.NoCompression)
  Dim entryStream = fileInArchive.Open()
  Dim fileToCompressedStream as new MemoryStream(bt2, 0, ms.ToArray().Length) 
  fileToCompressedStream.CopyTo(entryStream)
  fileToCompressedStream.Close()
  archive.Dispose()
  ms.Close()
  outStream.Close()
  Dim btFile = outStream.ToArray()

This works, I can unzip my file, etc. But I get "unexpected end" and due to that I can´t unzip the file in code. How to solve that?



Solution 1:[1]

i suggest you to use the 7zip.exe with Shell("7zip.exe -extract...") if this has helped you, accept my answer

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dazd-PKZ