Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi DLL) 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.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, BinData; ... procedure TForm1.Button1Click(Sender: TObject); var bd: HCkBinData; success: Boolean; b64Str: PWideChar; bd2: HCkBinData; begin bd := CkBinData_Create(); // This example will load a PDF and return it as a base64 string. success := CkBinData_LoadFile(bd,'qa_data/pdf/helloWorld.pdf'); if (success <> True) then begin Memo1.Lines.Add('Failed to load file.'); Exit; end; b64Str := CkBinData__getEncoded(bd,'base64'); Memo1.Lines.Add(b64Str); // Now write the base64 string back to the binary PDF file: bd2 := CkBinData_Create(); success := CkBinData_AppendEncoded(bd2,b64Str,'base64'); success := CkBinData_WriteFile(bd2,'qa_output/helloWorld.pdf'); CkBinData_Dispose(bd); CkBinData_Dispose(bd2); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.