Sample code for 30+ languages & platforms
VBScript

bz2 Compress File

Compress a file to the bz2 file format.

Chilkat VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

success = 0

' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

set bz2 = CreateObject("Chilkat.Bz2")

' Compress the file qa_data/hamlet.xml to create qa_output/hamlet.bz2
success = bz2.CompressFile("qa_data/hamlet.xml","qa_output/hamlet.bz2")
If (success <> 1) Then
    outFile.WriteLine(bz2.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine("Success.")

outFile.Close