I know that I should use an apostrophe if I want to show possession.
- Which form should I use?
- Are the forms interchangeable?
The answer depends upon what you wish to convey. They do mean different things.
'Directory path' is a compound noun. 'Path' is the main word and 'directory' is a modifier. If you are talking about the full path of a file for example, you could say,
"Be sure to specify the full directory path when saving."
If you are describing the path as a specific feature of the directory, you would use the possessive. In this case the 'directory' owns or possesses the 'path'.
"The directory's path along with the directory's name must not have any spaces or special characters."
If you can replace "directory's path" with "path of the directory" and the sentence still makes sense, then the apostrophe is correct and you could use that construction. In a lot of cases you could probably use either construction, but in general I use 'directory path' since I am usually writing about the full path and not the end directory.