在下载之前,使用delphi以编程方式从远程文件中获取文件大小 [英] programatically get the file size from a remote file using delphi, before download it

查看:79
本文介绍了在下载之前,使用delphi以编程方式从远程文件中获取文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Delphi下载之前,如何确定网络上托管的远程文件的大小(以字节为单位)?

How i can determine the size in bytes of a remote file hosted in the web, before download it, using Delphi?

预先感谢。

推荐答案

您可以使用Indy。

首先包含 IdHTTP

您可以通过以下方式获取大小:

You can retrieve the size this way:

procedure TFormMain.Button1Click(Sender: TObject);
var
  Http: TIdHTTP;
begin
  Http := TIdHTTP.Create(nil);
  try
    Http.Head('http://live.sysinternals.com/ADExplorer.exe');

    ShowMessage(IntToStr(Http.Response.ContentLength));
  finally
    Http.Free;
  end;
end;

这篇关于在下载之前,使用delphi以编程方式从远程文件中获取文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆