Delphi:如何将互联网上的文本文件加载成字符串? [英] Delphi: How to load a text file on the internet into a string?
本文介绍了Delphi:如何将互联网上的文本文件加载成字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如您所见,URL只是纯文本。我需要将这个文本从URL中加载到我的程序中的字符串中,我该怎么做?我搜索过,但没有发现任何东西。
PS:我需要最简单的代码。
感谢提前:)
解决方案
我将使用Indy的 TIdHTTP
,这样最简单的GET重载:
使用
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;
结束
结束
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 :)
解决方案
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;
这篇关于Delphi:如何将互联网上的文本文件加载成字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文