Results 1 to 5 of 5

Thread: Zipping & Unzipping Using Shell32.dll

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    Zipping & Unzipping Using Shell32.dll

    Ok i didn't like the idea of having to have a 3rd party application stuck in my apps directory so i asked for help on how to do it with the windows built in Shell32.dll. This is what i found out.
    To use this in your own project you need to make a reference to C:\Windows\System32\shell32.dll
    VB.net Code:
    1. 'Remeber to create a reference to C:\Windows\System32\shell32.dll
    2. 'Project > Add Reference > Browse and then navigate to the Windows\System32\shell32.dll.
    3.     Private Sub ExtractZip(ByVal zipFile As String, ByVal destination As String)
    4.         Dim shell As Shell32.Shell = New Shell32.Shell
    5.         shell.NameSpace(destination).CopyHere(shell.NameSpace(zipFile).Items, Nothing)
    6.         shell = Nothing
    7.     End Sub
    8.  
    9.     Public Sub ZipFile(ByVal strFileToZip, ByVal strTargetZip)
    10.         CreateEmptyZip(strTargetZip)
    11.         Try
    12.             CreateObject("Shell.Application").Namespace(strTargetZip).CopyHere(strFileToZip)
    13.         Catch ex As Exception
    14.  
    15.         End Try
    16.     End Sub
    17.  
    18.     Private Sub CreateEmptyZip(ByVal sPath As String)
    19.         Dim strZIPHeader As String
    20.  
    21.         strZIPHeader = Chr(80) & Chr(75) & Chr(5) & Chr(6) & String.Format(18, 0)
    22.         CreateObject("Scripting.FileSystemObject").CreateTextFile(sPath).Write(strZIPHeader)
    23.  
    24.     End Sub

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