Xceed Zip for COM/ActiveX on x86/x64 Documentation
Example topics
/ TestZipFile method and TestingFile event example for VB
In This Topic
TestZipFile method and TestingFile event example for VB
In This Topic
This example demonstrates how to test the integrity of the files contained within the the zip file "c:\Test\zip.zip".
The first function of the following code starts the test. For this example, nothing is specified in the FilesToProcess property, so all files inside the zip file will be tested. In this example we call TestZipFile with the bCheckCompressedData parameter set to True, so that the actual compressed data is checked too, not just the zip file's structure and file headers. The second function below is a handler written for the TestingFile event that displays (in a listbox) the filename of each file being tested, along with some other of the file's information. The third function below is a handler written for the Warning event, that adds detailed information about any encountered errors into the same listbox. The code assumes you have placed a button, a listbox and an Xceed Zip control on a form, and named them Button1, ListBox1 and XceedZip1 respectively.
We start with the handler for the button's click event. The code will start the testing.
Visual Basic
Copy Code
Sub Command1_Click()
Dim ResultCode As xcdError
Call XceedZip1.License( "your license key" )
' Set the name and path of the zip file to test XceedZip1.ZipFilename = "c:\test\zip.zip"
' Start testing the file (we use True here so that we also test the actual compressed data, not just the zip file's structure) ResultCode = XceedZip1.TestZipFile(True)
' Check the return value
If ResultCode <> xerSuccess Then MsgBox "Unsuccessful. Error #" & Str(ResultCode) & " occurred. " & "Description: " & _ XceedZip1.GetErrorDescription(xvtError, ResultCode) Else MsgBox "The tested zip file is completely error-free." End If End Sub
Here's the handler for the TestingFile event. It will add each tested file's name and info to the listbox.
Visual Basic
Copy Code
Private Sub XceedZip1_TestingFile(ByVal sFilename As String, ByVal sComment As String, _ ByVal lSize As Long, ByVal lCompressedSize As Long, _ ByVal nCompressionRatio As Integer, _ ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _ ByVal lCRC As Long, ByVal dtLastModified As Date, _ ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _ ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _ ByVal bEncrypted As Boolean, ByVal lDiskNumber As Long)