Even if you select a file in the dialog, the returned path will contain the folder in which the file is located.
But it is a good suggestion to maybe have an option in the function, if only directories are visible or all files. I will enter a suggestion for that in our database.
Thank you for the feedback!