FileNameJoin

FileNameJoin[{"name1","name2",}]

joins the namei together into a file name suitable for your current operating system.

FileNameJoin[{CloudObject[],"name2",}]

joins the namei to the path in the specified cloud object.

FileNameJoin[{LocalObject[],"name2",}]

joins the namei to the path in the specified local object.

Details and Options

  • The "namei" can be either individual names or file paths containing pathname separators.
  • FileNameJoin[{"","name1",}] gives an absolute file path beginning with a pathname separator.
  • FileNameJoin[,OperatingSystem->"os"] yields a file name in the format for the specified operating system. Possible choices are "Windows", "MacOSX", and "Unix".
  • FileNameJoin just assembles a file name; it does not actually search for the file specified.
  • FileNameJoin["name"] canonicalizes the file name "name", making pathname separators appropriate for your operating system. FileNameJoin also works with file-based URLs.

Examples

open allclose all

Basic Examples  (4)

Give a system-dependent file name:

Append the file name to a path:

On Windows, the share name is treated as a single unit:

Construct a cloud object from a directory cloud object and a file name:

Scope  (2)

Append file name to a cloud object:

Append paths to a local object:

Possible Issues  (1)

Deploying to a cloud path generated with FileNameJoin will fail if the parent object is not a directory:

Introduced in 2008
 (7.0)
 |
Updated in 2019
 (12.0)
2020
 (12.1)