Incus J 10 Posted December 18, 2020 I’ve added a folder of sample images to an FMX application. They appear listed in the Deployment manager. When the app is deployed on macOS, these images are included inside the application bundle in Contents/Resources/Startup/ How can I obtain a normal directory path to this internal folder, for internal use by the application? For example is there something like TPath.GetInternalResourcesFolder; ? I’m looking for the path to the folder only, rather than a full path to one single image file, so my app can load up all sample images in that folder when it starts up, without me having to reference each image filename individually in code. Share this post Link to post
Incus J 10 Posted December 18, 2020 (edited) I've found a post from April 2019 by Dave Nottage that looks like it might be adapted to do the trick: // Bit of a "hack" to get the exact paths of the pdf files deployed to /Contents/Resources/Startup LSourceName := TPath.GetDirectoryName(ParamStr(0)); LSourceName := TPath.Combine(StringReplace(LSourceName, '/MacOS', '', []), 'Resources/Startup/' + AFileName); ...seems to work OK 🙂. Would make a nice addition to the built in TPath class: class function TPath.GetAppResourcesPath:string; var appPath:string; begin appPath:=TPath.GetDirectoryName(ParamStr(0)); result:=TPath.Combine(StringReplace(appPath,'/MacOS','',[]),'Resources/Startup/'); end; ...though it would need adapting further to produce a sane result on all supported platforms. Edited December 18, 2020 by Incus J 1 Share this post Link to post
Doug Rudd 2 Posted December 19, 2020 In the deployment manager, if you put ".\assets\internal\" as the Remote Path, on start of your app it copies those files to a directory (if they dont already exist) that you can get with: tpath.GetDocumentsPath 1 Share this post Link to post
Guest Posted December 19, 2020 (edited) for this task, exist the "TPath" (a Record type) class functions and other procedure! http://docwiki.embarcadero.com/Libraries/Sydney/en/System.IOUtils.TPath Edited December 19, 2020 by Guest Share this post Link to post
Incus J 10 Posted January 6, 2021 On 12/19/2020 at 12:53 AM, Doug Rudd said: In the deployment manager, if you put ".\assets\internal\" as the Remote Path, on start of your app it copies those files to a directory (if they dont already exist) that you can get with: tpath.GetDocumentsPath That's very useful - thank you! Share this post Link to post