Newby Coder header banner

Path

What is Path in programming

Path is the location of a file or directory in a file system, which includes its name

Every file or directory present in a computer is associated with a specific path

This path can be used to access the file or directory

For example, the full path of the home directory of a user izaku in Linux :

/home/izaku/

and in windows :

C:\Users\izaku

A is expressed in a string of characters in which path components, separated by a delimiting character, represent each directory that appear in the hierarchy from the root directory

The delimiting character is most commonly the slash ("/"), backslash character ("\"), or colon (":"), though some operating systems may use a different delimiter

Absolute and relative paths

An absolute or full path points to the same location in a file system, regardless of the current working directory

In contrast, a relative path starts from some specific working directory, avoiding the need to provide the full absolute path

A filename can be considered as a relative path based at the current working directory

For example the relative path of a file with name wallpaper.jpg residing in /home/izaku is the filename itself, considering the working directory is /home/izaku

Path in URL

URL stands for Uniform Resource Locator

A URL is an address of a resource on the Web

Such resources can be an HTML page, a CSS document, an image, etc

A URL is composed of different parts, some mandatory and others optional

A path is the part of an URL which follows the domain part of the url and points to the resource

http://www.nc-xample.com/path/to/ncfile1.html?lang=en-US

In the above example, www.nc-xample.com is the domain name

And /path/to/ncfile1.html is the path to the html file

A path like this represents a physical file location on the Web server

But it may also be an abstraction to be handled by Web servers, which can decide which resource is to be sent based on the path