File Paths/References
File paths are used to reference the location of the file. Generally, file paths can be absolute or relative.
Operating System Paths
- Absolute Paths: Full path from the root directory.
Windows:
C:\Users\John\Documents\file.txt
Linux/macOS:
/home/john/documents/file.txt
-
Relative Paths: Path relative to the current directory.
./folder/file.txt (current directory)
../file.txt (parent directory)
Web Development Paths
- Absolute Paths: Full path from the domain.
https://www.byupathway.edu/student-support
- Relative Paths: Path relative to the current file.
../images/profile.png
../../images/castle.svg
Programming Language Paths
- JavaScript/Node.js:
const path = require('path'); path.join(__dirname, 'file.txt');
Python: /home/john/documents/file.py
- Relative Paths: Path relative to the current directory.
./folder/file.js (current directory)
../file.rb (parent directory)