Not able to zip or unzip using VB in VS 2010

Mar 21, 2012 at 10:37 AM
Edited Mar 22, 2012 at 5:57 AM

I'm using Ionic.Zip.Dll version 1.9 with my Visual Basic program and I've got it referenced. The particular problem I'm having is that I can unzip and zip the file flawlessly in Debug mode, however, after I Build the program and install it, I can neither unzip or zip the file. It doesn't give an exception or anything, it's almost as if the code for the process doesn't exist.


Here's the relevant code. (file names and directories changed due to security reasons)

Initial Start

Imports System
Imports System.IO
Imports System.Text
Imports Ionic.Zip

Public Class frm1
    
    'Declaring variables to store file paths to use later
    Dim Desktop As String
    Dim User As String
    Dim path4 As String
    Dim path5 As String
    Dim dotmcf As String
    Dim jarpath As String
    Dim savefolderpath As String
    Dim dotmcf As String
 Public Sub frm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Obtains the path to the desktop Desktop = My.Computer.FileSystem.SpecialDirectories.Desktop 'Obtains the username for access to the folder User = My.Computer.FileSystem.GetParentPath(Desktop) 'finding the folder vista/7/8 path4 = User & "\Testfolder\" 'finding the folder in XP path5 = User & "\Testfolder\" 'enables the dotmcf setting If IO.Directory.Exists(path4) Then dotmcf = path4 ElseIf IO.Directory.Exists(path5) Then dotmcf = path5 Else MsgBox("we cannot find your folder.") End If 'sets up the paths for zipping and unzipping the .jar savefolderpath = Desktop & "\JarUnzipped\" jarpath = dotmcf & "test.jar" The Zip code.



'unpackages the .jar file
    Private Sub btnUZip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUZip.Click
        'Checks for the folder on the desktop
        If IO.Directory.Exists(Desktop & "\JarUnzipped") Then
            System.IO.Directory.Delete(Desktop & "\JarUnzipped", True)

            'handles the unzipping of the .jar file
            Dim ZipToUnpack As String = jarpath
            Dim UnpackDirectory As String = savefolderpath
            Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
                Dim ze As ZipEntry
                ' here, we extract every entry, but we could extract conditionally,
                ' based on entry name, size, date, checkbox status, etc.   
                For Each ze In zip1
                    ze.Extract(UnpackDirectory, ExtractExistingFileAction.OverwriteSilently)
                Next
            End Using
        Else
            'handles the unzipping of the minecraft.jer file
            Dim ZipToUnpack As String = jarpath
            Dim UnpackDirectory As String = savefolderpath
            Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
                Dim ze As ZipEntry
                ' here, we extract every entry, but we could extract conditionally,
                ' based on entry name, size, date, checkbox status, etc.   
                For Each ze In zip1
                    ze.Extract(UnpackDirectory, ExtractExistingFileAction.OverwriteSilently)
                Next
            End Using
        End If

    End Sub
    'creates the new .jar file
    Private Sub btnZip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZip.Click
        'Checks for the folder on the desktop
        If IO.File.Exists(ziptocreate) Then
            System.IO.File.Delete(ziptocreate)
            'Handles the Zipping of .jar
            Dim itempaths As String() = _
              New String() {savefolderpath}
            Try
                Using zip As New ZipFile
                    Dim i As Integer
                    For i = 1 To itempaths.Length - 1
                        ' will add Files or Dirs, recursing and flattening subdirectories.
                        zip.AddItem(itempaths(i), "flat")
                    Next i
                    zip.Save(zippath & "test.jar")
                End Using
            Catch ex1 As Exception
                Console.Error.WriteLine("exception: {0}", ex1.ToString())
            End Try
        Else
            'handles the zipping of .jar
            Dim itempaths As String() = _
             New String() {savefolderpath}
            Try
                Using zip As New ZipFile
                    Dim i As Integer
                    For i = 1 To itempaths.Length - 1
                        ' will add Files or Dirs, recursing and flattening subdirectories.
                        zip.AddItem(itempaths(i), "flat")
                    Next i
                    zip.Save(zippath & "test.jar")
                End Using
            Catch ex1 As Exception
                Console.Error.WriteLine("exception: {0}", ex1.ToString())
            End Try
        End If

    End Sub

 

 

 

 

 

If anyone can spot anything that could be a reason it's not working after I build the program please let me know. As stated before, due to security reasons I have not included the code in it's entirety.


Many thanks, and sorry for posting so much code.






Edit: After closing Visual Studio last night and reopening it today, I can no longer zip or unzip the files using the above code in debug mode. The interesting thing about is that I don't get any exceptions or errors, it's like it's working but not producing a result.