- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi SizeToStr 文件大小转换KB MB GB TB
function SizeToStr(Size: int64): string;
const
K = int64(1024);
M = K * K;
G = K * M;
T = K * G;
begin
if size < K then
Result := Format('%d bytes', [size])
else if size < M then
Result := Format('%f KB', [size / K])
else if size < G then
Result := Format('%f MB', [size / M])
else if size < T then
Result := Format('%f GB', [size / G])
else
Result := Format('%f TB', [size / T]);
end;