File

File["path"]

is a symbolic representation of a location in the local file system.

Details

  • In File["path"], "path" specifies a possible path on the local file system. The path does not need to actually exist or refer to a file. »
  • File["path"] can use both absolute and relative paths. »
  • Information for a File may include the following properties:
  • "CreationDate"date when the file was created
    "LastAccessDate"time when the file was last accessed
    "LastModificationDate"time when the contents of the file were last modified
    "LastChangeDate"time when a file attribute was last changed
    "FileType"file type
    "ByteCount"file size in bytes
    "RawByteCount"how much space in bytes the file uses on disk
    "BlockCount"number of blocks the file uses
    "BlockSize"size of one block
    "FileAssociation"program associated with the file
    "UnixPermissionsCode" permissions in numeric form (e.g. 2774)
    "UnixPermissionsString"permissions in string form (e.g. "rwxrwsr--")
    "Device"name of the device on which the file lives.
    "UID"user ID
    "GID"group ID
    "SID"user's Security Identifier
    "OwnerName"owner of the file

Examples

open allclose all

Basic Examples  (2)

Get a snippet from a text file:

Without the File wrapper, the string itself would be used as data:

Formatting of a File object:

Scope  (3)

A File object need not point to an existing path:

Moreover, the path need not refer to a normal file:

Use File with an absolute path:

Use File with a relative path:

Properties & Relations  (2)

Each function will expand paths in a File object according to its own rules:

Get information about a File object:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2024_file, author="Wolfram Research", title="{File}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/File.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_file, organization={Wolfram Research}, title={File}, year={2019}, url={https://reference.wolfram.com/language/ref/File.html}, note=[Accessed: 21-November-2024 ]}