({{, (RefLink[DeleteFile, paclet:ref/DeleteFile])["file"]
deletes a file. }, {, (RefLink[DeleteFile, paclet:ref/DeleteFile])[{"(Subscript[file, 1])","(Subscript[file, 2])",…}]
deletes a list of files. }})

OpenersNotesSection(Spacer1)Details

(RefLink[DeleteFile, paclet:ref/DeleteFile]) returns (RefLink[Null, paclet:ref/Null]) if it succeeds in deleting files, and (RefLink[$Failed, paclet:ref/$Failed]) if it fails.

(RefLink[File, paclet:ref/File])["path"] may be used to specify a file name.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Copy a file and copy it into the new directory:

file = $InstallationDirectory<> "/Documentation/English/System/ExampleData/coneflower.jpg";

CopyFile[file,FileNameJoin[{$TemporaryDirectory,"coneflower.jpg"}]]

SetDirectory[DirectoryName[%]]

The file is there:

FileNames["*cone*.jpg"]

Delete the file:

DeleteFile[FileNameJoin[{$TemporaryDirectory,"coneflower.jpg"}]]

The file is no longer there:

FileNames["*cone*.jpg"]

OpenersExampleSection1(Spacer1)Scope  (1)

Copy the file specified as a (RefLink[File, paclet:ref/File]) object:

file = $InstallationDirectory<> "/Documentation/English/System/ExampleData/coneflower.jpg";
cfile=FileNameJoin[{$TemporaryDirectory,"coneflower.jpg"}];

CopyFile[File[file],File[cfile]]

DeleteFile[File[cfile]]

OpenersExampleSection2(Spacer1)Properties & Relations  (2)

Remove a local object:

Put[0,LocalObject["zero"]]

DeleteObject[LocalObject["zero"]]

Remove a persistent object:

PersistentValue["one","KernelSession"]=1;

DeleteObject[PersistentObject["one","KernelSession"]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[RenameFile, paclet:ref/RenameFile])  ▪  (RefLink[DeleteDirectory, paclet:ref/DeleteDirectory])  ▪  (RefLink[CopyFile, paclet:ref/CopyFile])  ▪  (RefLink[CreateFile, paclet:ref/CreateFile])  ▪  (RefLink[DeleteObject, paclet:ref/DeleteObject])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Naming and Finding Files, paclet:tutorial/NamingAndFindingFiles])}, {▪(RefLinkPlain[Manipulating Files and Directories, paclet:tutorial/ManipulatingFilesAndDirectories])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[File Operations, paclet:guide/FileOperations])}, {▪(RefLinkPlain[Importing and Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Managing Content in the Cloud, paclet:guide/ManagingContentInTheCloud])}})}})