Results 1 to 5 of 5

Thread: Unzip file using VB.net

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    71

    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

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    71

    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

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    71

    Re: Unzip file using VB.net

    Someone???

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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#.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width