Xbase++
Xbase++
Base64 Encode a File
_LANGUAGE_ to Base64 encode the contents of a file.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oFac
LOCAL cStrBase64
nSuccess := 0
// Get the contents of a file into a base64 encoded string:
oFac := CreateObject("Chilkat.FileAccess")
cStrBase64 := oFac:ReadBinaryToEncoded("c:/data/something.pdf", "base64")
IF (oFac:LastMethodSuccess != 1)
? oFac:LastErrorText
oFac:destroy()
RETURN
ENDIF
// Now write the string to a file:
nSuccess := oFac:WriteEntireTextFile("c:/data/something_pdf_base64.txt", cStrBase64, "us-ascii", 0)
IF (nSuccess != 1)
? oFac:LastErrorText
oFac:destroy()
RETURN
ENDIF
? "Success!"
oFac:destroy()