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 数值小数点后不保留0

Delphi 生成日志记录单元

Delphi遍历所有控件

Delphi中如何设置更改编译生成的exe文件的保存位置

Delphi 删除cookies及上网记录

Delphi xe2模拟键盘按键

Delphi 文件查找findfirst,findnext,findclose

Delphi: ttreeview 中禁止双击事件展开或关闭节点

Delphi tidhttp抓取页面信息

如何判断硬盘是fat32还是ntfs

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



打赏

取消

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

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

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

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

评论

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