Visual FoxPro
Visual FoxPro
Base64 Encode a File
_LANGUAGE_ to Base64 encode the contents of a file.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loFac
LOCAL lcStrBase64
lnSuccess = 0
* Get the contents of a file into a base64 encoded string:
loFac = CreateObject('Chilkat.FileAccess')
lcStrBase64 = loFac.ReadBinaryToEncoded("c:/data/something.pdf","base64")
IF (loFac.LastMethodSuccess <> 1) THEN
? loFac.LastErrorText
RELEASE loFac
CANCEL
ENDIF
* Now write the string to a file:
lnSuccess = loFac.WriteEntireTextFile("c:/data/something_pdf_base64.txt",lcStrBase64,"us-ascii",0)
IF (lnSuccess <> 1) THEN
? loFac.LastErrorText
RELEASE loFac
CANCEL
ENDIF
? "Success!"
RELEASE loFac