Sign in Join
FPDoc Onlineexperiment

DeleteFile function

In unit sysutils

Delete a file from the file system.

Declaration

pascal
function DeleteFile(const FileName: UnicodeString): Boolean

Description

DeleteFile deletes file FileName from disk. The function returns True if the file was successfully removed, False otherwise.

Errors

On error, False is returned.

See also

Example: ex31

pascal
Program Example31;

{ This program demonstrates the DeleteFile function }

Uses sysutils;

Var
  Line : String;
  F,I : Longint;

Begin
  F:=FileCreate('test.txt');
  Line:='Some string line.'#10;
  For I:=1 to 10 do
    FileWrite (F,Line[1],Length(Line));
  FileClose(F);
  DeleteFile('test.txt');
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.