Windows Saving location doesn't work

Discussion in 'Programming' started by Rommel76, Jul 13, 2019 at 6:51 AM.

  1. Rommel76

    Rommel76 Member

    Joined:
    Saturday
    Posts:
    3
    Hi everybody

    I am running the latest version 2.2.3.346, runtime v2.2.3.244

    I already disabled the sandbox restriction and anyway I am unable save the files in a defined directory .

    as follow the creation code :


    file = "http://www.**********.com/Test" // link al file
    des = "\Download\Upgrade.zip"
    download = http_get_file(file,des);
    size = 0 ;
    progress = 0 ;
    image_speed = 0

    The async http code :

    if ds_map_find_value(async_load,"id") = download {
    if ds_map_find_value(async_load,"status") = 1 {
    size = ds_map_find_value(async_load,"contentLength")
    progress = ds_map_find_value(async_load,"sizeDownloaded")

    }else if ds_map_find_value(async_load,"status") = 0{
    show_message("File download")}
    else {show_message("Download failed")
    }

    }


    Everything works , the file has been downloaded but has been saved properly only in the appdata directory only if I don't define any directory , with des = "\Download\Upgrade.zip" the file has been download but don't be saved anywhere , the same thing with any other folder i try .

    what can I do ? , I am trying and trying since many days for solve it but I am unable .

    Thanks a lot for any sugget
     
  2. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,479
    Backslashes are escape characters. The "\u" part of your path may be interpreted as the start of a hexadecimal unicode character sequence, for example.
    Windows-style paths need to be either carefully escaped (by replacing single backslashes with double backslashes), or forward slashes need to be used. The latter is probably easier.

    When using relative paths, you also need to be aware of what the path is relative to. Create a file with just a file name, see where it lands - that's your base path which your relative paths are relative to. If this is not the directory you want, you have to specify an absolute path. I assume you're trying to save stuff to the directory the .exe file is located in - in that case, your base path should be program_directory.


    Experiment around with what path settings work with file_text_open* and _close first, just to make sure the downloading part isn't messing up things. Once you know which approach works, switch over to the downloaded file.
     
  3. Lonewolff

    Lonewolff Member

    Joined:
    Jan 8, 2018
    Posts:
    1,088
    In paths you can either use double backslashes or a forward slash like so;

    \\folder\\file
    /folder/file
     
    rIKmAN, Joe Ellis and TsukaYuriko like this.
  4. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,272
    Yal, Joe Ellis and Lonewolff like this.
  5. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,272
    I wasn't shutting anyone down, I was letting them know the version numbers they posted aren't the latest version like they said they were using, but the versions they posted could easily be typos.

    You should seriously think twice before you make posts, most of them are profile post spam or low effort rubbish that add nothing of value to the forum or conversation, but this one is bordering on racist.

    Grow up.
     
    Last edited by a moderator: Jul 14, 2019 at 8:37 AM
  6. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,735
    Topic tidied.

    @Joe Ellis :
    The above comment is fairly spot on and any more comments from you like the one I've removed and you'll get a warning. While I can understand that your comment was not intended as racist in any way, it was perceived as racist, so take care with what you post on the forums in the future please.
     
    Last edited: Jul 14, 2019 at 9:43 AM
  7. Rommel76

    Rommel76 Member

    Joined:
    Saturday
    Posts:
    3
    Sorry .... I disappeared due working trip ....

    I apologize for my bad typo , runtime v2.2.3.344, but anyway I am still unable to get any result
    In the reality yes , this is my target but really I am unable to understand how do it ...
    I try with :
    des = program_directory + "Test.zip" ;
    but in the end the file still being saved in the appdata directory :(:(:(
    the only "success I had" is using :
    des = "/program_directory/test.zip"

    In this case it save the file in the root of my D:\ hard disk with a file called "program_directory " with inside the file "test.zip"

    But the program is installed in d:\Gametest\

    Will try again tomorrow :mad::mad::mad: there must be a solution but of course I am not enough skilled

    Thanx for the support and the messages of everybodies
     
  8. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,479
    Are you testing this from within the IDE or from a compiled project? (You mentioned that it's installed, but just to make sure...)

    Also, did you ever output the path generated by your code to verify that it points to the correct location?
     
  9. Joe Ellis

    Joe Ellis Member

    Joined:
    Aug 30, 2016
    Posts:
    857
    des = "/program_directory/test.zip" will make a directory in the hard drive base dir cus program_directory is put as a string, cus it's in inverted commas,

    The other way should save it in the program directory, but if you're running it in "runner" ei. running it pressing play inside gamemaker, the program_directory is the directory that the "runner.exe" is in. and that's never useful when you're testing it from inside gamemaker.

    But if the program is installed in d:\gametest\, Is the program a single executable? cus then the files extracted upon run would probably get put in a temp or local app data folder, and the program_directory might then be set to that cus it's more relevant.

    If I was you, I'd make a small .cfg text file, in the "local app data" directory when the program gets installed. and in it contain the paths that the program needs, then all it has to do is simply open "setup.cfg", and then read each of the paths it needs.

    Alot of programs write to the appdata folder when they install.. alot of the data I don't know what it's for, cus who can, but if you look through the folders for programs alot of them have text files which hold the directory the program is installed in. I think an exe file, is unable to know\find out where it is on the hard-drive, I'm not sure, I think they normally either have some thing where they look up the registry, or use a text file located in appdata\program_name\
     
    Last edited: Jul 17, 2019 at 12:20 AM
  10. Rommel76

    Rommel76 Member

    Joined:
    Saturday
    Posts:
    3
    I proceed from a compiled ide everytime , the think i am unable to understand is that if I check the program_directory with a show_message (program_directory) the path is right ...

    I tryed by the way in "copy and paste " the official example about http_get_file from the help .... changing the url of the download .... but anyway doesn't save the file in the folder deigned ...
     
  11. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,479
    Sorry to ask the same question again, but are you running the project from within the IDE (using the Run or Debug option), or are you exporting the game as an executable/zip/installer and then running the exported game? "from a compiled IDE" sounds like a mixture of both. ^^'

    For reference, you need the second option.

    Could you share an example of the generated path output and post the exact code you used to generate it?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice