F: file of Byte;
begin
if OpenDialog1.Execute then begin
AssignFile(F, OpenDialog1.FileName);
{$I-}//关闭io检查
Reset(F);
{$I+}//打开io检查
if IOResult = 0 then
MessageDlg('File size in bytes: ' + IntToStr(FileSize(F)),
mtInformation, [mbOk], 0)
else
MessageDlg('File access error', mtWarning, [mbOk], 0);
end;
//绝对管用!
function GesSelfSize: integer;
var
f: file of byte;
begin
filemode = 0;//读写属性设置为只读,这样才不会出错!
assignfile(f, application.exename);
reset(f);
Result := filesize(f);
closefile(f);
end;