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) Base64 Encode a FileDelphi DLL to Base64 encode the contents of a file.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, FileAccess; ... procedure TForm1.Button1Click(Sender: TObject); var fac: HCkFileAccess; strBase64: PWideChar; success: Boolean; begin // Get the contents of a file into a base64 encoded string: fac := CkFileAccess_Create(); strBase64 := CkFileAccess__readBinaryToEncoded(fac,'c:/data/something.pdf','base64'); if (CkFileAccess_getLastMethodSuccess(fac) <> True) then begin Memo1.Lines.Add(CkFileAccess__lastErrorText(fac)); Exit; end; // Now write the string to a file: success := CkFileAccess_WriteEntireTextFile(fac,'c:/data/something_pdf_base64.txt',strBase64,'us-ascii',False); if (success <> True) then begin Memo1.Lines.Add(CkFileAccess__lastErrorText(fac)); Exit; end; Memo1.Lines.Add('Success!'); CkFileAccess_Dispose(fac); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.