The following code uses the Zip method to compress the file "c:\test\my file.dat" into the zip file "c:\test\my test.zip". You should check the Zip 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 topic to find out what went wrong. The following code assumes you placed a button and an Xceed Zip control on a form and named them 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 two below XceedZip1.FilesToProcess = "c:\test\my file.dat" XceedZip1.ZipFilename = "c:\test\my test.zip"
' Start zipping ResultCode = XceedZip1.Zip
' Check the return value. If ResultCode <> xerSuccess Then MsgBox "Unsuccessful. Error # " & Str(nErr) & " occurred. " & _ "Description: " & XceedZip1.GetErrorDescription(xvtError, ResultCode) Else MsgBox "File(s) successfully zipped." End If End Sub
|