Zip file length ?

M

Masahiro Ito

Use ICSharpCode.SharpZipLib

Can view files in zip library. Files are being created the wrong size when
unzipped. Sample code I found in this newsgroup. I thought I could change
from s.length to onefile.size, but that doesn't work. Any idea?

Thanks.

Dim zipfile As New ICSharpCode.SharpZipLib.Zip.ZipFile("S:\Temp\test.zip")
Dim onefile As ZipEntry = zipfile.GetEntry("test.txt")
Dim s As System.IO.Stream = zipfile.GetInputStream(onefile)
Dim length As Long = s.Length

Dim bytes(length) As Byte
s.Read(bytes, 0, length)
Dim newfile As New System.IO.FileStream("test.txt",
IO.FileMode.Create)
newfile.Write(bytes, 0, length)
newfile.Flush()
newfile.Close()
 
M

Masahiro Ito

Use ICSharpCode.SharpZipLib

Can view files in zip library. Files are being created the wrong size
when unzipped. Sample code I found in this newsgroup. I thought I
could change from s.length to onefile.size, but that doesn't work.
Any idea?

Thanks.

Dim zipfile As New
ICSharpCode.SharpZipLib.Zip.ZipFile("S:\Temp\test.zip")
Dim onefile As ZipEntry = zipfile.GetEntry("test.txt")
Dim s As System.IO.Stream = zipfile.GetInputStream(onefile)
Dim length As Long = s.Length

Dim bytes(length) As Byte
s.Read(bytes, 0, length)
Dim newfile As New System.IO.FileStream("test.txt",
IO.FileMode.Create)
newfile.Write(bytes, 0, length)
newfile.Flush()
newfile.Close()

<bump>
 

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