What is the difference between these two pathnames? Is /
necessary to put in start for going in a folder?
assets/myImg.png
/assets/myImg.png
What is the difference between these two pathnames? Is /
necessary to put in start for going in a folder?
assets/myImg.png
/assets/myImg.png
You haven't mentioned an OS, so given the leading /
I'll assume we're on a Unix-like system.
/assets/myImg.png
This is an absolute path. It's going to look in the root directory of your file system for a folder called assets
and go from there.
assets/myImg.png
This is a relative path. It's going to look in the current working directory, which is likely the directory where you started your current program. If you're using this from the command line, it's going to look starting from the current directory of the shell (i.e. the thing you change with cd
).
/assets/myImg.png
is an absolute path. It means no matter where do you call the path from it's always the same.assets/myImg.png
is relative path to your current directory