Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#18

Re: Dateigröße formatieren?

  Alt 25. Nov 2005, 17:52
Delphi-Quellcode:
function FileSizeToStr(const ASize: Int64): string;
const
  Units: Array[0..8] of string = ('Byte', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
                                                                              // Ab hier wird es unwahrscheinlich ^^
var
  Index: Integer;
begin
  Assert(ASize >= 0);
  Index := Trunc(ln(ASize) / ln(2) / 10);
  Result := Format('%.2f %s', [ASize / (1 shl (Index * 10)), Units[Index]]);
end;
OT: Was ist denn EB, ZB und YB ?
Ich kenne nur bis PetaByte
Michael
  Mit Zitat antworten Zitat