How to get folder path in dired-mode?

elisp, emacs, lisp

Solution

There's `dired-directory`, however this Q&A indicates that it is unreliable in certain circumstances, and that `default-directory` is a better choice.

- C-hv `default-directory` RET

- C-hv `dired-directory` RET

Problem

I can get the file path with: ``` (message (file-name-directory (or buffer-file-name load-file-name))) ``` But if the buffer in dired-mode, the above code evaluates to nil. How can I get the folder path in dired-mode with elisp?

Original source

Related problems