The reasons can be different.
Please see my two comprehensive answers which explain how to work with all kinds of paths:How to find my programs directory
),How to find my programs directory
("special folders", working directory
I want to reiterate that there are no situation when using any hard-coded file path can be useful. In all cases, paths should be calculated during run time based on user input, configuration files, etc, based on the methods I described above.—SA