0

After working pretty hard on a personal project, it is now time to release the application and distribute it.

And suddenly, I realize that all my resources (images, sqlite database etc...) are located in the debug folder... and I fear this was a mistake from the start :)

As you can see on the following screenshot, here is my folder hierarchy:

enter image description here

Pretty wrong isn't it ?

My questions : what should I do ? Is there a way out of this ? Where should I have put my resources in the first place ?

Because, when I launch the compiled release, it works of course, but only because the resources are linked with their full path to them. I suspect it won't work for someone else. God, I feel so stupid not to have thought about that in the first place...

Kromster
  • 7,181
  • 7
  • 63
  • 111
Mathmathou
  • 373
  • 4
  • 15
  • 1
    Note that this is mainly a matter of opinion, and that could get your question put on hold. – Rudy Velthuis May 18 '17 at 23:36
  • Would it be too hard to move them to a separate directory, independent of target and platform? Are the links to them hard-coded, or relative to some directory? I would have put them in `C:\DEVS\Embarcadero\DRAMA2017\Resources`, but you are free to put them wherever you like. – Rudy Velthuis May 18 '17 at 23:39
  • Well, in fact, the link to the sqlite database are "hard coded" in the TFDConnection parameters, and I fear the path is a full one and not a relative one... – Mathmathou May 18 '17 at 23:41
  • How hard would it be to change these hard-coded links? Are there very many? Also consider having a global variable that links to the resources directory and then make other resource links relative to that. If necessary, set properties that link to a resource at runtime. – Rudy Velthuis May 19 '17 at 00:11
  • Possible duplicate of [Setting up a large software system in Delphi](http://stackoverflow.com/questions/8957128/setting-up-a-large-software-system-in-delphi) – Jerry Dodge May 19 '17 at 01:38
  • Any application should never rely on writable data in the same directory anyway. Also, even if you did, you should make sure all your paths are relative to the application at least. – Jerry Dodge May 19 '17 at 01:40
  • @JerryDodge - thanks for the advise, that is something I'll definitely take into account for my next application. Also, making all the paths relative to the application is exactly what I want. Can you tell me or point me in the right direction on how to do so ? Would you advise putting the database file into the user folder ? – Mathmathou May 19 '17 at 03:11
  • @Mathmathou Actually I was just referencing this one the other day, specifically the accepted answer: http://stackoverflow.com/a/5329520/988445 As far as where to store files, look at `TPath` and its documentation. – Jerry Dodge May 19 '17 at 03:15
  • Relative to application may or may not be what you want. It depends. Impossible for us to say from here. – David Heffernan May 19 '17 at 06:46
  • @DavidHeffernan - sorry to bother : [I rephrased my question](https://stackoverflow.com/questions/44123752/setting-a-relative-path-to-sqlite-database-with-delphi-and-firedac) to make it less a matter of opinion. If you could have a look I'd be very grateful – Mathmathou May 22 '17 at 23:59
  • @JerryDodge - sorry to bother : [I rephrased my question](https://stackoverflow.com/questions/44123752/setting-a-relative-path-to-sqlite-database-with-delphi-and-firedac) to make it less a matter of opinion. If you could have a look I'd be very grateful, the example you linked was intereseting but far from my comprehension level :) – Mathmathou May 23 '17 at 00:03
  • Found the solution : added a datamodule, used it in all my units and all queries using the FDConnection on the datamodule with a relative path to database file. Thanks to all for your participation – Mathmathou May 23 '17 at 07:29

0 Answers0