函数:友好显示字节
function BytesFriendly(const Bytes : integer):string;
begin
if Bytes < 1024 then
begin
Result := Format('%s', [IntToStr(Bytes)]) + 'B';
Exit;
end;
if (Bytes >= 1024) and (Bytes < (1024 * 1024)) then
begin
Result := Format('%n', [Bytes / 1024]) + ' KB';
Exit;
end;
if (Bytes >= (1024*1024)) and (Bytes < (1024 * 1024 * 1024)) then
begin
Result := Format('%n', [Bytes / (1024 * 1024)]) + ' MB';
Exit;
end;
if Bytes >= (1024*1024*1024) then
begin
Result := Format('%n', [Bytes / (1024 * 1024 * 1024)]) + ' GB';
Exit;
end;
end;
begin
if Bytes < 1024 then
begin
Result := Format('%s', [IntToStr(Bytes)]) + 'B';
Exit;
end;
if (Bytes >= 1024) and (Bytes < (1024 * 1024)) then
begin
Result := Format('%n', [Bytes / 1024]) + ' KB';
Exit;
end;
if (Bytes >= (1024*1024)) and (Bytes < (1024 * 1024 * 1024)) then
begin
Result := Format('%n', [Bytes / (1024 * 1024)]) + ' MB';
Exit;
end;
if Bytes >= (1024*1024*1024) then
begin
Result := Format('%n', [Bytes / (1024 * 1024 * 1024)]) + ' GB';
Exit;
end;
end;

浙公网安备 33010602011771号