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;