var
myFile : TextFile;
begin
// Let us open a text file
AssignFile(myFile, 'Test.txt');
ReWrite(myFile);
// And write a single line to it
WriteLn(myFile, 'Hello World');
// Then close it
CloseFile(myFile);
// And finally erase it
Erase(myFile);
// If we try to raise it
again, we'll raise an exception
try
Erase(myFile);
except
on E : Exception do
ShowMessage('Cannot erase : '+E.Message);
end;
end;