• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML [solved] get_open_filename_ext() Starting directory not working?

hdarren

Member
I am trying to make use of the get_open_filename_ext() function to load a file. But I am having trouble getting it to automatically look in a specific folder.

When I leave the dir argument empty it defaults to the place Windows last loaded a file from, which is to be expected. I tried changing the argument to "F:" and it correctly starts at that drive. However when I try and add any folder it just defaults back to the desktop implying that it's not finding the folder.

I've tried: "F:\Logs", "F:\Logs\\", "F:/Logs", "F:/Logs/" and all just do not work. :(

What am I doing wrong?
 
M

Marcus12321

Guest
The program is run in a sandboxed mode, which means it is locked to only using specific folders that it is allowed to access. You can't just access any part of the hard drive. There is an extension on the market place that does allow you to escape the sandbox.
 

hdarren

Member
I don't think that's true.
On the Windows and Mac OS platforms there is one way to save and load files from outside of the sandbox and that is using the functions get_open_filename and get_save_filename. Both of these functions will require that the user select an area for loading and saving and the return string can then be used in the rest of the file functions to bypass the sandbox.
You may also add in a directory to start the search from. An important thing to note when using this function is that it grants you certain permissions for that file, for the duration of your game. So, once you get the file path from the user, you can access it again and again without having to ask.
As you can see in my test it worked fine with "F:" but I can't get it to work with sub folders.
 
Top