1
I need to get the file size from Delphi 7 but am getting I/O error because the file is being used. (The file is a . exe and is open)
I’ve tried the following codes:
function TamanhoDoArquivo(arquivo: string): LongInt;
var
lArquivo: file of byte;
begin
with TFileStream.Create(arquivo, fmOpenRead or fmShareExclusive) do
try
Result := Size;
finally
Free;
end;
end;
And also:
function TamanhoDoArquivo(arquivo: string): LongInt;
var
lArquivo: file of byte;
begin
try
AssignFile(lArquivo, arquivo);
try
reset(lArquivo);
Result := FileSize(lArquivo);
finally
CloseFile(lArquivo)
end;
except
on E:Exception do
Showmessage('Erro');
end;
end;
Is there any way to get the size of . exe even if it is open? Thank you