DownloadFile on macOS

Find quick help here to get you started with Hollywood
Post Reply
Jan
Posts: 26
Joined: Sun Sep 17, 2017 10:28 am
Location: Slovakia
Contact:

DownloadFile on macOS

Post by Jan »

Hi, I have a command like this in my script:

DownloadFile("http://internet.com/" ..
"Hello.jpg", {File = "Hello.jpg"})

It downloads the given file to the same folder where the script is located. The behaviour is the same on Windows and macOS.

However, if I compile a standalone executable, while Windows .exe still downloads it to the same folder, macOS app downloads it to itself: App > Contents > Resources

How can I download it to the same folder where the app itself is located? Or elsewhere?

Many thanks.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: DownloadFile on macOS

Post by airsoftsoftwair »

Jan wrote: Sun Feb 24, 2019 11:43 am How can I download it to the same folder where the app itself is located? Or elsewhere?
You just have to pass the path along the file name in the "File" tag, e.g.

Code: Select all

DownloadFile("http://internet.com/" .. "Hello.jpg", {File = "/Applications/Hello.jpg"})
You can get the location of the app using GetProgramInfo(). Note, however, that it is not a good idea to write directly to the location where the app is installed because your app might not be allowed to write to this location. You could use the folder that is returned in "AppData" by GetSystemInfo().
Post Reply