DeleteFile

DeleteFile["file"]

deletes a file.

DeleteFile[{"file1","file2",}]

deletes a list of files.

Details

  • DeleteFile returns Null if it succeeds in deleting files, and $Failed if it fails.
  • File["path"] may be used to specify a file name.

Examples

open allclose all

Basic Examples  (1)

Copy a file and copy it into the new directory:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

The file is there:

In[4]:=
Click for copyable input
Out[4]=

Delete the file:

In[5]:=
Click for copyable input

The file is no longer there:

In[6]:=
Click for copyable input
Out[6]=

Scope  (1)

Properties & Relations  (2)

See Also

RenameFile  DeleteDirectory  CopyFile  CreateFile  DeleteObject

Tutorials

Introduced in 1991
(2.0)
| Updated in 2016
(11.0)