Path

How do your find a file - you have to find a pathway to it.

What is a File Path?

A file path is a string of text that describes the location of a file or folder within a file system. It shows the “route” you need to take, starting from a specific point (such as the root directory or current directory), to get to a particular file or folder.


Key Points


Types of File Paths

  1. Absolute Path

    • Shows the full, complete address to the file/folder, starting from the root directory.
    • Example (Windows):
      C:\Users\Alice\Documents\Report.docx
      
    • Example (Linux/macOS):
      /home/alice/Documents/report.txt
      
  2. Relative Path

    • Shows the address relative to your current directory.
    • Example:
      If you’re already in C:\Users\Alice, a relative path to the document above would be:
      Documents\Report.docx
      

Path Separators


Components of a Path

Example:
/Users/beth/photos/vacation.jpg
Here, Users, beth, and photos are directories, and vacation.jpg is the file.


Visual Example

Given a structure like:

/
 └── home/
       └── alice/
               ├── Documents/
               │      └── notes.txt
               └── Pictures/
                       └── photo.jpg

Summary

A file path tells you (and your computer) precisely where a file lives in your file system. It’s like an address for a file!