Correct way to convert size in bytes to KB, MB, GB Delphi -
what correct way convert size in bytes kb, mb, gb in delphi.
i suppose want delphi solution. try this
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 := 0; while bytes > power(1024, + 1) inc(i); result := formatfloat('###0.##', bytes / intpower(1024, i)) + ' ' + description[i]; end;
Comments
Post a Comment