Help SharpZipLib Unzip from MemoryStream


G

Giuseppe

I'm write a code with SharpZipLib for Zip files in MemoryStream...
I don't succeed to make Unzip....

This my code for Zip :

Private function ZipFiles(Files() as string) as MemoryStream
Dim StrFile As String
Dim ms As MemoryStream = New System.IO.MemoryStream
Dim s As ZipOutputStream = New ZipOutputStream(ms)
s.SetLevel(5)
For Each StrFile In Files
Dim fileName As String = StrFile
Dim fs As FileStream = File.OpenRead(fileName)
Dim buffer() As Byte = New Byte(fs.Length) {}
fs.Read(buffer, 0, buffer.Length)
Dim entry As ZipEntry = New ZipEntry(fileName)
s.PutNextEntry(entry)
s.Write(buffer, 0, buffer.Length)
Next
s.Finish()

Return ms
 
Ad

Advertisements

S

Samuel R. Neff

What's your code for unzip? What problems are you having? Have you
looked at the many good samples in the docs?

Also there are two mechanisms for unzip, ZipFile which gives random
file access and ZipInputStream which gives sequential file access.

One thing to note is that in some cases the zip library will only read
files in a small amount at a time--even as little as one byte at a
time--so you have to read the files in a loop filling a buffer and
tranferring to the other stream. Assuming you can read the file into a
single buffer will eventually lead to errors (and is a waiste of
resources).

HTH,

Sam



B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top