Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

Zip an Entire Directory Tree

Download Chilkat 32-bit Zip ActiveX (.msi) (includes objects for .zip, .gz, .bz2, and .Z)

Download All 32-bit Chilkat ActiveX Components (.zip)

Download All 64-bit Chilkat ActiveX Components (.zip)

This VB Example program shows how to do Zip compression in Visual Basic. It Zips an entire directory tree into a Zip archive.

' VB Zip Compression Example Program
' Visual Basic program to Zip all files in a directory tree.
Private Sub Command2_Click()
    
    ' Create a ChilkatZip2 object
    Dim ZipFile As ChilkatZip2
    Set ZipFile = New ChilkatZip2
    ZipFile.UnlockComponent UnlockCode.Text
    ZipFile.NewZip OutputZip.Text
    
    ' Add the directory and all files recursively to the Zip object
    ' At this point, the Zip object simply contains references to
    ' files that will be added and compressed when WriteZip is called.
    ' No compression has taken place, and the Zip file has not yet
    ' been created on disk.  This happens when WriteZip is called.
    success = ZipFile.AppendFiles(SourceDir.Text, 1)
    If (success = 0) Then
        MsgBox ZipFile.LastErrorText
        Exit Sub
    End If
    
    ' See if anything was added.
    If (ZipFile.NumEntries = 0) Then
        ZipStatus.Caption = "Error, no files added to the Zip archive."
        Exit Sub
    End If
    
    ' Compress and write to disk.
    ' This is when the Zip file is actually created.
    success = ZipFile.WriteZip()
    If (success = 0) Then
        MsgBox ZipFile.LastErrorText
        Exit Sub
    End If
    
    ZipStatus.Caption = "Success." + vbCrLf + Str(ZipFile.NumEntries) + " files and directories zipped"
        
    ' Demonstrate how to get the contents of the Zip as XML
    Dim fnum As Integer
    fnum = FreeFile()
    Open "zipDirectory.xml" For Output As #fnum
    Print #fnum, ZipFile.GetDirectoryAsXML()
    Close #fnum
    
    ZipFile.CloseZip
    Set ZipFile = Nothing
    
End Sub

Private Sub Form_Load()
    OutputZip.Text = CurDir$ + "\dirTree.zip"
    
End Sub


 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.