473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Ok, I solved the zip error, but I can't unzip

Hi! Finally I figure out what was wrong... "objZipEntry.size = strmFile" I wasn't giving the right file length... But now, I have issue with the unzip function... I can't unzip it, the unzip function return true but its invalid parameter when I try to set the image to the picture box....

Private Overloads Function Unzip(ByVal strSource As String, ByVal
strFileToExtract As String, ByRef newms As MemoryStream) As Boolean

If File.Exists(strSource) Then

Dim ZipStream As ZipInputStream

Try

ZipStream = New ZipInputStream(File.OpenRead(strSource))

ZipStream.Password = "your own prefered password here"

Dim TheEntry As ZipEntry = ZipStream.GetNextEntry()

Dim size As Integer

Do Until TheEntry Is Nothing

If Path.GetFileName(TheEntry.Name) = strFileToExtract Then

Dim data(1024) As Byte

newms = New MemoryStream

Dim bw As New BinaryWriter(newms)

Dim buffer(1024) As Byte

Dim length As Integer

Dim dataToRead As Long = TheEntry.Size

While dataToRead > 0

length = ZipStream.Read(buffer, 0, 1024)

bw.Write(buffer, 0, length)

ReDim buffer(1024) ' Clear the buffer

dataToRead = dataToRead - length

End While

Return True

End If

TheEntry = ZipStream.GetNextEntry()

Loop

Catch e As Exception

Finally

ZipStream.Close()

End Try

End If

End Function

Nov 21 '05 #1
1 1823

Hello Jean

i have just send you a working example , inclusive the way to bind the
unzipped stream to a picturebox

i hope it helps :-)
regards

Michel Posseth

"Jean Christophe Avard" <NO***@M.BITCH> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
Hi! Finally I figure out what was wrong... "objZipEntry.size = strmFile" I
wasn't giving the right file length... But now, I have issue with the unzip
function... I can't unzip it, the unzip function return true but its invalid
parameter when I try to set the image to the picture box....

Private Overloads Function Unzip(ByVal strSource As String, ByVal
strFileToExtract As String, ByRef newms As MemoryStream) As Boolean

If File.Exists(strSource) Then

Dim ZipStream As ZipInputStream

Try

ZipStream = New ZipInputStream(File.OpenRead(strSource))

ZipStream.Password = "your own prefered password here"

Dim TheEntry As ZipEntry = ZipStream.GetNextEntry()

Dim size As Integer

Do Until TheEntry Is Nothing

If Path.GetFileName(TheEntry.Name) = strFileToExtract Then

Dim data(1024) As Byte

newms = New MemoryStream

Dim bw As New BinaryWriter(newms)

Dim buffer(1024) As Byte

Dim length As Integer

Dim dataToRead As Long = TheEntry.Size

While dataToRead > 0

length = ZipStream.Read(buffer, 0, 1024)

bw.Write(buffer, 0, length)

ReDim buffer(1024) ' Clear the buffer

dataToRead = dataToRead - length

End While

Return True

End If

TheEntry = ZipStream.GetNextEntry()

Loop

Catch e As Exception

Finally

ZipStream.Close()

End Try

End If

End Function
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: italo | last post by:
Greetings. There is a way to zip and unzip files. its like a Winzip or WinRar or PowerArchiver.. but i need to .NET ZIP and unZIP these files. ex. <name_of_file>.zip i dont know if theses...
3
by: Jan | last post by:
Hi, Is there a way to unzip a file from C# since I need to download a zip file from the server, unzip it and verify its contents, all through the same program. Thanks in advance, Jan
4
by: DataSmash | last post by:
I need to unzip all zip file(s) in the current directory into their own subdirectories. The zip file name(s) always start with the string "usa" and end with ".zip". The code below will make the...
11
by: Hari Sekhon | last post by:
I do import zipfile zip=zipfile.ZipFile('d:\somepath\cdimage.zip') zip.namelist() then either of the two: A) file('someimage.iso','w').write(zip.read('someimage.iso'))
4
by: spdude | last post by:
Hi, We are using Dynazip to unzip files on our server. It works perfectly on a test box but when the same code is deployed to the production, it chokes. It creates the unzipped file with 0...
3
by: DaveO | last post by:
My apologies for individually posting this to multiple newsgroups - my ISP won't allow multiple posts. I'm not a C programmer, so I'm looking for someone to modify some UnZip code for a...
7
dima69
by: dima69 | last post by:
I'm looking for the solution to Zip / Unzip files in VB6 / VBA. I've searched the web and found several solutions (zlib.dll, Info-Zip, DynaZip, PKZip, ...). The question is which one is the best ? ...
1
by: sudhivns | last post by:
Looking for Zip/Unzip handling code. Unzip feature should extract the files including the absolute path. Eg: Input data.zip contains 1. folder IMP 2. some *.txt files. On Unzip, i choose...
6
by: rajarora | last post by:
Hi , I faced a very strange problem when I unzip a zip file on my solaris workstation. Actually I wanted to transfer a folder, say it TEST which contains some sub-folders inside it from windows to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.