Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   File of byte y filesize (https://www.clubdelphi.com/foros/showthread.php?t=58197)

madmai 11-07-2008 18:36:18

File of byte y filesize
 
Código Delphi [-]
var
   f: file of Byte;
   size: Longint;
   S: string;
   y: Integer;
begin
  if OpenDialog1.Execute then
  begin
    AssignFile(f, OpenDialog1.FileName);
    Reset(f);
    try
      size := FileSize(f);
      S := 'File size in bytes: ' + IntToStr(size);
      y := 10;
      Canvas.TextOut(5, y, S);
      y := y + Canvas.TextHeight(S) + 5;
      S := 'Seeking halfway into file...';
      Canvas.TextOut(5, y, S);

      y := y + Canvas.TextHeight(S) + 5;
      Seek(f, size div 2);
      S := 'Position is now ' + IntToStr(FilePos(f));
      Canvas.TextOut(5, y, S);
    finally
      CloseFile(f);
    end;
  end;
end;

Con el siguiente codigo cuando elijo un fichero de mas de 2 gigas me sale un size en negativo que he de hacerlo para interpretarlo, y poner el tamaño real que tiene en megas, cuando es inferior a 2 gigas no tengo problema, gracias de antemano

dec 11-07-2008 18:49:43

Hola,

Por este truco de Lepe, es posible que lo que ocurra es que la función "FileSize()" no pueda retornar el tamaño de archivos de más de 2 GB. Echa un vistazo al truco que digo, porque, existe una solución a eso.


La franja horaria es GMT +2. Ahora son las 06:36:17.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi