Delphiでバイト単位のサイズをKB、MB、GBに変換する正しい方法は何ですか?
7219 次
2 に答える
10
Delphi ソリューションが必要だと思います。これを試して
uses
Math;
function ConvertBytes(Bytes: Int64): string;
const
Description: Array [0 .. 8] of string = ('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
var
i: Integer;
begin
i := 0;
while Bytes > Power(1024, i + 1) do
Inc(i);
Result := FormatFloat('###0.##', Bytes / IntPower(1024, i)) + ' ' + Description[i];
end;
于 2015-05-30T18:07:29.460 に答える