需要uses IdCoderMIME;
function TForm1.Base64E(Path: string): string;
var
filepath: string;
filestream: TFileStream;
EncoderMIME: TIdEncoderMIME;
encode_result: string;
begin
EncoderMIME := TIdEncoderMIME.Create(self);
filestream := TFileStream.Create(Path, fmOpenRead);
result := EncoderMIME.Encode(filestream);
filestream.Free;
end;