Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base64 to Binary (Delphi)

Tags:

delphi

I used Binary to Base64 function that you answered : Binary to Base64 (Delphi)

I successfully encode a file to base64 string and write it to MsSQL2008 database, but i want to ask a question: How can i write this file to disk again with using EncdDecd.pas?

like image 265
user1135768 Avatar asked Nov 28 '22 11:11

user1135768


1 Answers

As always, David answered sufficiently. Although I can't resist to give a slightly different solution using some of the goodies from the recent Delphi versions.

procedure DecodeFile(const base64: AnsiString; const FileName: string);
var
  stream: TBytesStream;
begin
  stream := TBytesStream.Create(DecodeBase64(base64));
  try
    stream.SaveToFile(Filename);
  finally
    stream.Free;
  end;
end;
like image 55
Uwe Raabe Avatar answered Dec 11 '22 01:12

Uwe Raabe