Function to delete the file from disk. Any files are deleted (even files with attributes such "read only", "hidden", "system").

 

Syntax

function DeleteFile(sFileName:string): integer;

 

Parameters and return

Parameter

Type

Value

sFileName

string

file name and path.

 

Function result

Result

Value

0

all OK, file deleted successfully;

-1

specified file or path does not exist;

-2

file deletion failed. For example, the file was busy by another program, operating system, or this file is on CD and can not be deleted.

 

Example

begin
  DeleteFile('c:\temp\123.txt');
end.

See also

FileExists