Name

Erase Procedure

Syntax

procedure Erase(var F: File);
procedure Erase(var F: TextFile);

Description

Erase deletes the file that is assigned to F. The file should be closed, but with a filename assigned to it. Erase is not a real procedure.

Errors

  • If AssignFile has not been called, Erase raises I/O error 102.

  • If the file cannot be deleted, Erase reports an I/O error using the Windows error code. In particular, if the file is open, the Windows error code is 32 (file in use), and if the file is read-only, the Windows error code is 5 (access is denied).

See Also

AssignFile Procedure, CloseFile Procedure, File Keyword, IOResult Function, Rename Procedure, TextFile Type

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.