What is a relative path ?

Undraw File Manager Re Ms29

About

A relative path is a path that does not start with a root (prefix)

It is relative to another path that is unknown. You need to transform it as absolute|absolute path before accessing any file.

Relative path vs Absolute Path

Below is an example of a relative because it does not start with a root (prefix)

joe/foo 

Below is an example of an absolute path because it does start with a root (the Linux root)

/joe/foo 

Advantages vs Disadvantages

Portable

Relative file paths are much more portable because they don't depend on the whole path.

Therefore your files can be installed in two different directories. Via a configuration, your application can calculate the two differents absolute path

Not an file identifier

A relative path is not a file identifier while an absolute path is.

Therefore, it does not identify uniquely a file and needs to be transformed as absolute path.

How to get an absolute path ?

To get an absolute path from a relative path, you need to concatenate:

By default, the absolute path applied is the working directory (known also as current or default directory).





Discover More
Undraw File Manager Re Ms29
File - File System (filesystem)

A file system (often also written as filesystem) is an application that stores and organizes files and their data (content). Essentially, it organizes these files for storage, organization, manipulation,...
Undraw File Manager Re Ms29
File System - Path

in a file system. A file is identified by its path through the file system. A file path is a hierarchical URI where: scheme is the scheme that represents the file system such as: file (default)...
Undraw File Manager Re Ms29
What is a file system root or drive ? (known as prefix)

The prefix is a path concept that is used to handle: root directories on UNIX platforms, drive specifiers, root directories, and UNC pathnames on Microsoft Windows platforms Prefix can be: A...
Undraw File Manager Re Ms29
What is an absolute path ?

A path is absolute when it starts with a root (prefix). It contains all the information needed to locate the file. Inside a file system, the absolute path is the file identifier. Absolute path: This...



Share this page:
Follow us:
Task Runner