Overview of Path Names


A location in the file system is completely specified by a "path". The path may consist of different components, such as drives, directories, and file names. The CSplitpath class is used to work with the components of a path to set, get, or change the location in a networked file system. This class follows the following the Microsoft UNC, or "Universal Naming Convention".

A complete path specification consists of the following components:

    Machine name

    Drive Name

    Directory Names

    File Name

    Extension

Putting these components together, a file is uniquely identified in the file system by its full path in the following form:

     \\Machine name\Drive Name:\Directory Names\File Name.Extension

The Directory Name component consist of one or more directories. This is the reason Directory Names is plural. When a directory follows the first directory, it is often called a "subdirectory". The combinationMachine name + Drive name + Directory names is called the "folder". Double slashes at the beginning are used to identify the machine on a network. When there is no network, a file is identfied starting only with its drive name.

Representation as a string

The path specification above includes \ characters which can cause some confusion if not used propertly when coding a script. If the path or its components is specified in a literal string, then double backslashes \\ must be used in place of \ in order to prevent single \ from being interpreted as an "escape sequence" that uses a normal character for a special meaning. Thus you would specify the full path name above like this:

     "\\\\Machine name\\Drive Name:\\Directory Names\\File Name.Extension"

For example, in a literal string, you would specify the newline character as "\n", so that the n character is handled specially. If you instead used "\\n", then the result would be printed as \n, in other words a \ character followed by an n character.

Related Topics

CSplitpath Class