delphi 计算文件大小


本文整理自网络,侵删。

 //整型
function TForm1.IFormatByte(nSize: Int64): string;
begin
  if nSize > 1073741824 then
    Result := FormatFloat('###,##0.00G', nSize / 1073741824)
  else if nSize > 1048576 then
    Result := FormatFloat('###,##0.00M', nSize / 1048576)
  else if nSize > 1024 then
    Result := FormatFloat('###,##00K', nSize / 1024)
  else
    Result := FormatFloat('###,#0B', nSize);
  if Length(Result) > 2 then
    if Result[1] = '0' then
      Delete(Result, 1, 1);
end;

function TForm1.FFormatByte(fSize: Double): string;
begin
  if fSize > 1073741824.0 then
    Result := FormatFloat('###,##0.00G', fSize / 1073741824.0)
  else if fSize > 1048576.0 then
    Result := FormatFloat('###,##0.00M', fSize / 1048576.0)
  else if fSize > 1024.0 then
    //Result := FormatFloat('###,##00K', fSize / 1024.0)
    Result := FormatFloat('###,##00.00K', fSize / 1024.0)
  else
    Result := FormatFloat('###,#0B', fSize);
  if Length(Result) > 2 then
    if Result[1] = '0' then
      Delete(Result, 1, 1);
end;

相关阅读 >>

Delphi idhttpserver接收http get请求解码问题

Delphi 双击隐藏tabsheet

Delphi 获取窗口矩形的四种方法: getclientrect、clientrect、getwindowrect、boundsrect

Delphi is 与 as 运算符举例

Delphi 通过 shgetspecialfolderlocation、shgetpathfromidlist 函数获取常用路径

Delphi窗口界面必学的知识

Delphi 删除字符串中首个字符

Delphi xe使用tjsonobject解析json数据

Delphi函数指针,用于加载dll

Delphi xe增强的rtti妙用--动态创建包中的窗口类

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



打赏

取消

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

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

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

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

评论

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