Ir al contenido


Foto

[TRUCO DELPHI] Convertir un Tamaño de Archivo a su Valor de Cadena.


  • Por favor identifícate para responder
No hay respuestas en este tema

#1 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 26 agosto 2016 - 08:45

[TRUCO DELPHI] Convertir un Tamaño de Archivo a su Valor de Cadena.

 

Deben de adicionar esta Unidad


delphi
  1. uses SysUtils;


delphi
  1. function BytesToStr(const i64Size: Int64): string;
  2. const
  3. i64GB = 1024 * 1024 * 1024;
  4. i64MB = 1024 * 1024;
  5. i64KB = 1024;
  6. begin
  7. if i64Size div i64GB > 0 then
  8. Result := Format('%.2f GB', [i64Size / i64GB])
  9. else if i64Size div i64MB > 0 then
  10. Result := Format('%.2f MB', [i64Size / i64MB])
  11. else if i64Size div i64KB > 0 then
  12. Result := Format('%.2f KB', [i64Size / i64KB])
  13. else
  14. Result := IntToStr(i64Size) + ' Byte(s)';
  15. end;

Saludos!


  • 1




IP.Board spam blocked by CleanTalk.