How to save an in-game screenshot to the Downloads folder

Godot 4

I made a feature of being able to take a screenshot in my game, but I wanted to know if there was a specific file path i need to use for a player to be able to save it in their Downloads folder. i read the docs for file paths, but couldn’t really get it to work :frowning:

there’s a screenshot of the code attached below!

Do you want to let them pick where their screenshots are stored?

ideally i just want it to get saved in their downloads folder only

Ok, well keep in mind you are assuming everyone is using Windows. As long as you only create a Windows build of your game for release, this will work. (Every operating system stores files differently.)

For Windows 11 you would use the file path of:

user://../../../../Downloads/

Then append your screenshot name. Keep in mind that cluttering up someone’s Downloads directory without telling them could be a bad user experience. Also keep in mind that when your game gets uninstalled, the screenshots will stay.

For more information, check this out the docs:

1 Like

You can get the downloads dir by:

OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS)

Works on different operating systems.

Edit: typo

4 Likes

thank you this helps a lot!!

oh amazing thank you for the help!!

just an fyi to ppl who find this post - i used tassup’s solution and i kept dragonforge-dev’s tips in mind. the solution works but it doesn’t save directly to the Download’s folder, it saves under the ‘Users’ folder under the C:/ drive of the Windows system at least. I’m happy with this since it’s in an easier location to access than having the player navigate to Appdata, but this is where I got to!