Sample code for 30+ languages & platforms
VBScript

Base64 Encode a File

_LANGUAGE_ to Base64 encode the contents of a file.

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

' Get the contents of a file into a base64 encoded string:
set fac = CreateObject("Chilkat.FileAccess")
strBase64 = fac.ReadBinaryToEncoded("c:/data/something.pdf","base64")
If (fac.LastMethodSuccess <> 1) Then
    outFile.WriteLine(fac.LastErrorText)
    WScript.Quit
End If

' Now write the string to a file:
success = fac.WriteEntireTextFile("c:/data/something_pdf_base64.txt",strBase64,"us-ascii",0)
If (success <> 1) Then
    outFile.WriteLine(fac.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine("Success!")

outFile.Close