Erase a file System unit
 procedure Erase ( var FileHandle : File; ) ;
The Erase procedure attempts to erase a file given by the FileHandle.
The file name must have been assigned to the given FileHandle by the AssignFile  routine.
If the file does not exist, then the EInOutError exception is raised.
Related commands
DeleteFile Delete a file specified by its file name
Rename Rename a file
RenameFile Rename a file or directory
 Author links

 Download this web site as a Windows program.

Example code : Create a simple file, then try to delete it twice
  myFile : TextFile;

  // Let us open a text file
  AssignFile(myFile, 'Test.txt');

  // And write a single line to it
  WriteLn(myFile, 'Hello World');

  // Then close it

  // And finally erase it

  // If we try to raise it again, we'll raise an exception
    on E : Exception do
      ShowMessage('Cannot erase : '+E.Message);
Show full unit code
   Cannot erase : File not found
Delphi Programming Neil Moffatt 2002 - 2020. All rights reserved.  |  Home Page