That particular function will always bring up a dialog. However, there are locations (e.g. temp folders or the plugin folder, for which you don’t need access permissions and you can create a temp file in there). You can also access a random location on disk by providing a file path. If you search for any of those key words in the forum you will find a plethora of threads (there’s practically at least one person per week asking this ). E.g check out this post, from myself a while ago.
I would also recommend looking through the docs for file access and read it in full to understand what you can do with and without permissions from the user.