Xceed Zip Compression Library Documentation
Unzip method example for VB
Example topics > Unzip method example for VB

The following code uses the Unzip method to unzip the file "readme.txt" from the zip file "c:\test\my test.zip" into the directory "c:\test\unzipped files". If the directory does not already exist, it will be created automatically. You should check the Unzip method's return value once you are done – if it is xerSuccess , the operation was successful. Otherwise, look up the error code in the error codes list to find out what went wrong. This code assumes you have a button and an Xceed Zip control on a form, named Command1 and XceedZip1 respectively.

Visual Basic Copy Code

Sub Command1_Click() 

   Dim ResultCode As xcdError  

   Call XceedZip1.License( "your license key" ) 

   ' All properties keep their default values except the four below 
   XceedZip1.FilesToProcess = "readme.txt" ' The file to unzip 
   XceedZip1.PreservePaths = False ' In case file is stored in the  

   ' zip file with a path, we need to make sure the path is 
   ' removed so that the file will match with "readme.txt" 
   XceedZip1.UnzipToFolder = "c:\test\unzipped files" 
   XceedZip1.ZipFilename = "c:\test\my test.zip" 

   ' Start unzipping 
   ResultCode = XceedZip1.Unzip  

   ' Check the return value. 
   If ResultCode <> xerSuccess Then 
      MsgBox "Unsuccessful. Error # " & Str(nErr) & " occurred. " & _
             "Description: " & XceedZip1.GetErrorDescription(xvtError, ResultCode) 
   Else 
      MsgBox "File(s) successfully unzipped." 
   End If 
End Sub