creates a file with name file.


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.


open allclose all

Basic Examples  (1)

Create a file:

Check the presence of the new file:

Delete the file:

The file is no longer there:

Scope  (1)

Create a file in the current directory:

The file is present in the current directory:

Delete the file:

Properties & Relations  (1)

CreateTemporary[] is essentially equivalent to the zero-argument CreateFile[]:

Introduced in 2016
Updated in 2016