Extrair o tamanho de um arquivo

 

Utilize a função:

 

function TamanhoArquivo(Arquivo: string): Integer;

begin

  with TFileStream.Create(Arquivo, fmOpenRead or fmShareExclusive) do

  try

    Result := Size;

  finally

   Free;

  end;

end;

 

O retorno da função é o tamanho em bytes do arquivo. Se você quiser saber o tamanho em Kb, divida o Size por 1024, mas terá que alterar o retorno da função para Double , por exemplo:

 

 

por Luciano Pimenta