Sample code for 30+ languages & platforms
Visual FoxPro

Convert any File to Base64 (and back)

Demonstrates how to get the contents of any file as a base64 string, and then write it back.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loBd
LOCAL lcB64Str
LOCAL loBd2

lnSuccess = 0

loBd = CreateObject('Chilkat.BinData')

* This example will load a PDF and return it as a base64 string.
lnSuccess = loBd.LoadFile("qa_data/pdf/helloWorld.pdf")
IF (lnSuccess <> 1) THEN
    ? "Failed to load file."
    RELEASE loBd
    CANCEL
ENDIF

lcB64Str = loBd.GetEncoded("base64")
? lcB64Str

* Now write the base64 string back to the binary PDF file:
loBd2 = CreateObject('Chilkat.BinData')
lnSuccess = loBd2.AppendEncoded(lcB64Str,"base64")
lnSuccess = loBd2.WriteFile("qa_output/helloWorld.pdf")

RELEASE loBd
RELEASE loBd2