Einzelnen Beitrag anzeigen

hhluemmel

Registriert seit: 14. Mär 2005
Ort: Hamburg
49 Beiträge
 
#6

Re: BlobFeld in eine XML Speichern Lösung

  Alt 20. Mai 2008, 09:50
File in Base64 codieren

Delphi-Quellcode:
uses ....
   XMLDoc,XMLIntf,MSXML;



function TForm1.GetBase64CodeFile(pFileName: string):String;
var
 cFileData : TStringStream;
 cFileString : String;
 cFileStream : TFileStream;
begin
  if (pFileName<>'') then
  begin
    if FileExists(pFileName) then
     begin
       cFileData := TStringStream.Create(cFileString);
       cFileStream := TFileStream.Create(pFileName,fmOpenRead);
       try
         cFileStream.Position := 0;
         cFileData.CopyFrom(cFileStream,cFileStream.Size);
         Result := Base64.Encode(cFileData.DataString);
         Application.ProcessMessages;
       finally
         cFileData.Destroy;
         cFileStream.Destroy;
       end;
     end;

  end;
end;
cData Segment erstellen

Delphi-Quellcode:
procedure TForm1.AddFileData;
var
  cData : IDOMCDATASection;
begin
  cData := xmlDocument.DOMDocument.createCDATASection(xmlCData);
  xmlNode.DOMNode.appendChild(cData);
end;
  Mit Zitat antworten Zitat