CreateFile

CreateFile["file"]

creates a file with name file.

CreateFile[]

creates a file in the default area for temporary files on your computer system.

Details and Options

  • If "file" has no pathname separators, CreateFile creates a file in your current working directory.
  • A relative path is interpreted with respect to the current working directory.
  • CreateFile only creates the file; it does not open it.
  • The file created can subsequently be opened for reading or writing in binary or text mode.
  • CreateFile returns the full name of the file it creates, and $Failed if it cannot create the file.
  • CreateFile has attribute Listable.
  • CreateFile[] creates a file in the directory specified by the current value of $TemporaryDirectory.
  • The default setting CreateIntermediateDirectories->True specifies that intermediate directories should be created as needed.
  • File["path"] may be used to specify a file name.

Examples

open allclose all

Basic Examples  (1)

Create a file:

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

Check the presence of the new file:

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

Delete the file:

In[3]:=
Click for copyable input

The file is no longer there:

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

Scope  (1)

Properties & Relations  (1)

See Also

DeleteFile  RenameFile  CopyFile  CreateDirectory  $PathnameSeparator  LocalObject

Tutorials

Introduced in 2016
(10.4)