Entwickler-Ecke

Internet / Netzwerk - txt vom web in ein tmemo laden


blackbirdXXX - So 25.05.03 11:05
Titel: txt vom web in ein tmemo laden
Wie kann ich eine Textdatei von einem Webserver (z.B.: http://domain.tld/datei.txt) in ein memo laden?
Mit

Delphi-Quelltext
1:
memo1.lines.LoadFromFile('http://domain.tld/datei.txt');                    

geht es nicht


GruppeCN - So 25.05.03 11:22

Geht ganz einfach:


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
uses ... URLmon, ShellAPI;

function download(url, pfad:string): Boolean;
begin
  Result := UrlDownloadToFile(nil, PChar(url), PChar(pfad), 0nil) = 0;
end;

procedure TForm1.Create(Sender: TObject);
begin
  if download('http://www.domain.de/datei.txt',ExtractFilePath(Paramstr(0)) + 'datei.txt'then begin
  memo1.lines.loadfromfile(ExtractFilePath(Paramstr(0)) + 'datei.txt');
end
else ShowMessage('Fehler beim Download!');


blackbirdXXX - So 25.05.03 11:34

Danke : :)