Einzelnen Beitrag anzeigen

Benutzerbild von dahead
dahead

Registriert seit: 16. Mai 2005
620 Beiträge
 
#21

Re: Dateigröße formatieren?

  Alt 5. Dez 2005, 10:49
Zitat von Khabarakh:
Viel zu lang :mrgreen: .
Delphi-Quellcode:
function FileSizeToStr(const ASize: Int64): string;
const
  Units: Array[0..8] of string = ('Byte', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
var
  Index: Integer;
begin
  Assert(ASize >= 0);
  Index := Trunc(ln(ASize) / ln(2) / 10); // <-- hier
  Result := Format('%.2f %s', [ASize / (1 shl (Index * 10)), Units[Index]]);
end;
*scnr*
Bei meinem Delphi 7 kommt leider in der Idx Spalte ein Fehler inkompatible Typen. Ln erwartet einen Wert vom Typ Real.
  Mit Zitat antworten Zitat