What is the difference between an absolute and a relative path?

后端 未结 3 1023
小蘑菇
小蘑菇 2021-01-11 12:41

I am asking because I am working on a project for school. Yes this is homework. But, I\'m trying to understand a little bit more, though.

This is one example of wha

3条回答
  •  自闭症患者
    2021-01-11 13:30

    An absolute path is the whole path name required to access the location in the file system.
    For example: C:\Program Files\Internet Explorer\iexplorer.exe

    Where as a relative path is in relation to some landmark, usually your main executable files location or the 'start in' location set when you open the program.

    For example if your main executable is in C:\Program Files\ the relative path to iexplorer.exe is Internet Explorer\iexplorer.exe.

    This is done usually when you don't always know where the file will absolutely be, like which drive letter it will be installed in or which folder it will be under.

    However for a good example, if your file came with your program and you know your programs installation structure, you can use relative pathing to find all your files no matter where your program is installed as opposed to abolute pathing where your program would need to be installed in the exact same location each time.

提交回复
热议问题