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
    "FileAttributes"list of attributes assigned to the file
    "Permissions"file access permissions as specified by Permissions
    "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
    "AccessControlList"ACL associated with the file

Examples

open all close all

Basic Examples  (3)

Load a string template from disk:

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

Get a snippet from a text file:

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

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

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

Formatting of a File object:

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

Scope  (1)

Properties & Relations  (2)

Introduced in 2016
(11.0)