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.
  • With the setting OverwriteTarget->True, CreateFile truncates the existing file to zero size.
  • File["path"] may be used to specify a file name.

Examples

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[]:

Wolfram Research (2016), CreateFile, Wolfram Language function, https://reference.wolfram.com/language/ref/CreateFile.html (updated 2019).

Text

Wolfram Research (2016), CreateFile, Wolfram Language function, https://reference.wolfram.com/language/ref/CreateFile.html (updated 2019).

BibTeX

@misc{reference.wolfram_2020_createfile, author="Wolfram Research", title="{CreateFile}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/CreateFile.html}", note=[Accessed: 10-May-2021 ]}

BibLaTeX

@online{reference.wolfram_2020_createfile, organization={Wolfram Research}, title={CreateFile}, year={2019}, url={https://reference.wolfram.com/language/ref/CreateFile.html}, note=[Accessed: 10-May-2021 ]}

CMS

Wolfram Language. 2016. "CreateFile." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/CreateFile.html.

APA

Wolfram Language. (2016). CreateFile. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CreateFile.html