tags:

views:

1670

answers:

2

In Windows Explorer you can extract a compressed folder (a zip file)

Is there an API or command line to extract a zip file using the same method programatically?

+2  A: 
  1. Check Compress Zip files with Windows Shell API and C#
  2. You could use SharpZipLib which is free for a dot net project.
abmv
Thanks abmv. But the first link requires an external zip.exe file. Do you know where that zip.exe is from?Apparently SharpZipLib cannot unzip zip files created using WinZip, can it?
I see it is from the other project. I wonder why can't you combine it into one
+2  A: 

You can use this VBScript script:

'Adapted from http://www.robvanderwoude.com/vbstech_files_zip.html

strFile = "c:\filename.zip"
strDest = "c:\files"

Set objFSO = CreateObject("Scripting.FileSystemObject")

If Not objFSO.FolderExists(strDest) Then
    objFSO.CreateFolder(strDest)
End If

UnZipFile strFile, strDest

Sub UnZipFile(strArchive, strDest)
    Set objApp = CreateObject( "Shell.Application" )

    Set objArchive = objApp.NameSpace(strArchive).Items()
    Set objDest = objApp.NameSpace(strDest)

    objDest.CopyHere objArchive
End Sub