Holds the return code of the last I/O operation System unit
 function IOResult : Integer;
The IOResult function retrieves the result of the last I/O (file input/output) operation.
This number is zero if the operation succeeded, or a positive number if it failed.
Use IOResult when you have disabled the default Delphi IO error trapping. When $IOChecks is On, Delphi raises exceptions for the errors. When Off, Delphi does not raise exceptions, requiring the code to inspect IOResult.
Warning : retrieval of the IO result is a one-off activity - the retrieval resets the value to 0.
Related commands
$IOChecks When on, an IO operation error throws an exception
GetLastError Gives the error code of the last failing Windows API call
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Create a directory twice, catching the error code
  error : Integer;

  // Try to create a new subdirectory in the current directory
  // Switch off I/O error checking
  {$IOChecks off}

  // Did the directory get created OK?
  error := IOResult;
  if error = 0
  then ShowMessage('Directory created OK')
  else ShowMessageFmt('Directory creation failed with error %d',[error]);

  // Try to create the directory again - this will fail!
  error := IOResult;  // Save the return code
  if error = 0
  then ShowMessage('Directory created OK again')
  else ShowMessageFmt('Repeat creation failed with error %d',[error]);

  // Delete the directory to tidy up

  // Switch IO checking back on
  {$IOChecks on}
Show full unit code
   Directory created OK
   Repeat creation failed with error 183
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page