|
-
Apr 13th, 2008, 03:25 AM
#1
Thread Starter
Lively Member
Unzip file using VB.net
Hello,
i wrote a program that uses J# to unzip fiile.
It works just fine.
but when i'm trying to unzip a zip file that inside the zip there are 2 files to unzip and each of them is n diffrent directory it dosnt unzip anything.
code: this function unzip(uncompress) the file.
Code:
Public Shared Function Uncompress(ByVal strZipFileName As String, ByVal strLocation As String) As Boolean
Try
Dim oFileInputStream As New java.io.FileInputStream(strZipFileName)
Dim oZipInputStream As New java.util.zip.ZipInputStream(oFileInputStream)
Dim bTrue As Boolean = True
Dim sbBuf(1024) As SByte
Dim First As Integer = 0
While 1 = 1
Dim oZipEntry As java.util.zip.ZipEntry = oZipInputStream.getNextEntry()
If oZipEntry Is Nothing Then Exit While
If oZipEntry.isDirectory Then
If Not My.Computer.FileSystem.DirectoryExists(strLocation & oZipEntry.getName) Then
My.Computer.FileSystem.CreateDirectory(strLocation & oZipEntry.getName)
End If
Else
Dim oFileOutputStream As New java.io.FileOutputStream(strLocation.Replace("\", "/") & oZipEntry.getName())
While 1 = 1
Dim iLen As Integer = oZipInputStream.read(sbBuf)
If iLen < 0 Then Exit While
oFileOutputStream.write(sbBuf, 0, iLen)
End While
oFileOutputStream.close()
End If
End While
oZipInputStream.close()
oFileInputStream.close()
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
Thanks
-
Apr 13th, 2008, 04:01 AM
#2
Re: Unzip file using VB.net
Are you saying you have a .zip file with two more .zip files inside it? Either the API you're using will need to give you a way to 'navigate' or 'search' inside the given .zip file, or you'll need to unzip the given .zip, then go through the output folder looking for more .zip files.
-
Apr 13th, 2008, 04:07 AM
#3
Thread Starter
Lively Member
Re: Unzip file using VB.net
NO,
inside the zip file there are 2 regular files that each has a diffrent path nside the zip file.
the function i'm uses dosnt extract any of the files.
Thanks again
-
Apr 13th, 2008, 04:38 PM
#4
Thread Starter
Lively Member
Re: Unzip file using VB.net
-
Apr 14th, 2008, 01:02 AM
#5
Re: Unzip file using VB.net
There are two ZIP submissions in the VB.NET CodeBank forum. One by myself, which uses #ZipLib, and other that uses J#. I'm not sure whether the one that uses J# would be able to help you with your question or not but it would be worth a look. I know that in mine I did take this situation into account. That said, some people did report issues with extracting files using my code and i never did get to look at it. I'm thinking of redoing that code for the latest version of #ZipLib. I'd probably recommend going with #ZipLib given that Microsoft have discontinued J#.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|