delphi 以Bytes为单位获取文件大小


本文整理自网络,侵删。

 
// maxium supports 2G
function getFileSizeInBytes(const fn: string): integer;
var
  f: File of byte;
begin
  Result := -1;
  if (FileExists(fn)) then
  begin
    try
      {$I-}
      AssignFile(f, fn);
      Reset(f);
      {$I+}
      if (IOResult = 0) then
      begin
        Result := FileSize(f);
      end
      else
      begin
        Result := 0;
      end;
    finally
      {$I-}CloseFile(f);{$I+}
    end;
  end;
end;

相关阅读 >>

Delphi删除文件

Delphi stringgrid 加载excel表格文件内容自动宽度

Delphi 内存池

Delphi实现阿里云印刷文字识别_身份证识别

Delphi程序将自身可执行文件拷贝到u盘的代码

Delphi android gps服务

Delphi edit呈横线效果

Delphi 搜索字符串

Delphi webbrowser载入自定义html内容并显示

Delphi inttostransi

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...