Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: How to load a text file on the internet into a string?

On my program I have a function that checks for the current version of the program, which it gets from the url: www.tablemaster.webs.com/versioninfo.txt

As you can see, at the URL is just plain text. I need to load this text from the URL into a string on my program, how will I go about doing this? I've searched around but found nothing..

PS: I need the simplest code possible..

Thanks in advance :)

like image 589
James Avatar asked Nov 27 '22 17:11

James


2 Answers

I would use Indy's TIdHTTP with it's easiest GET overload this way:

uses
  IdHTTP;

procedure TForm1.Button1Click(Sender: TObject);
var
  S: string;
  IdHTTP: TIdHTTP;
begin
  IdHTTP := TIdHTTP.Create(nil);
  try
    S := IdHTTP.Get('http://www.tablemaster.webs.com/versioninfo.txt');
    ShowMessage(S);
  finally
    IdHTTP.Free;
  end;
end;
like image 123
TLama Avatar answered Dec 05 '22 15:12

TLama


you can use TIEHTTP component from myfxboard.. to load txt file from url with TIEHTTP:

http.ExecuteURL('www.tablemaster.webs.com/versioninfo.txt');
Memo1.Lines.Add(http.sl.Text);
like image 29
S.FATEH Avatar answered Dec 05 '22 16:12

S.FATEH