Pathname definition
A pathname is a string that specifies the precise location of an object (such as a file or directory) in a file system. Pathnames allow the operating system and software applications to access data stored on the device or network.
See also: executable file, file management system
Pathname components
Pathnames can be broken down into distinct elements separated by directory separators (slashes for Unix and backslashes for Windows). As an example, let’s analyze “C:\Users\User\Documents\file.txt”, a pathname used by the Windows operating system.
The “C:” in our example is the root directory — the highest-level directory in a file system. In Windows, this is the drive letter followed by a colon (“C:” for the C drive).
The “User” and “Documents” are directories (folders) — containers that can hold files and other directories. A series of directory names separated by directory separators (such as slashes or backslashes) specifies the path to the desired object. In our example, the “User” directory holds the “Documents” directory, which contains our desired file.
The “file.txt” is the name of the file you want to access, the final part of a pathname. Pathnames can lead to both files and directories.
Pathname types
- Absolute pathnames provide the complete path from the root directory to a specific file or directory.
- Relative pathnames specify the location of an object in relation to the current working directory — it doesn't start from the root directory.