Finding Resources in a WIndows project

Ok… I have an app written for OSX… in which I have dragged a number of XML files as source data.
When the app starts up… it searches the file path App.ExecutableFile.Parent.parent.child(“Resources”) for the appropriate files and deals with them accordingly. The nice thing about this is the as the app grows and the design soldifies I don’t need to worry about how many files, or what the names were the I placed in the project. It just scans that directory and it works perfectly.

NOW… for OSX that is a good solution… but for WINDOWS that method doesn’t work obviously… but each “file” can be referred to by the name in the ide, the problem is I would have to make sure that everytime I added, remove or consolidated some of those XML files that a hardcoded chunk of code would have to be kept up to date

process_xml  first_xml_file
process_xml second_xml_file
etc.

So here it the question… twofold

a) Is there an easy way the WIndows can self-inspect and determine those names? (I am doubting there is)
b) is there a way to write a PRE-BUILD script that would scan a file directory, WRITE a method (similar to above)… and then INCLUDE that method in the build?

Solution “B” would allow me the same flexiblity that I have with OSX now… with the benefit… if I forget to actually drag a file into the IDE, but it is in the scanned folder. the compile will fail because it wrote code to refer to a file that the IDE didn’t have yet.

At this point I don’t want to make an installer (for either OSX or Win) containing these as individual files…(I have 17 as of now)… The other solution would be to compile all the XML into one file and have a single known “name”… but I’d like to avoid that in lieu of future flexibiltiy.

[quote=24994:@Dave S]Ok… I have an app written for OSX… in which I have dragged a number of XML files as source data.
When the app starts up… it searches the file path App.ExecutableFile.Parent.parent.child(“Resources”) for the appropriate files and deals with them accordingly. The nice thing about this is the as the app grows and the design soldifies I don’t need to worry about how many files, or what the names were the I placed in the project. It just scans that directory and it works perfectly.

NOW… for OSX that is a good solution… but for WINDOWS that method doesn’t work obviously…[/quote]

Not so obviously…

I keep my Windows exe in a folder named for the app and have a folder next to the exe (and Libs Folder if present) called “Resources” and put a shortcut on the desktop to the exe. I use a pre build step to create the resource folder and move the files into it.

So why can’t you do that? Logic is the same as for OSX then.

Karen… that is EXACTLY what I asked.

But I don’t want to deploy a “resources” folder" external to the applicatoin… I do not want the XML files easily accessable to the end user (yes I know on OSX they are easily visible)

That is not what I am doing. I’m just creating the resource folder and moving the files into it so the exe can find them, not creating methods on the fly.

i guess the question is why not.

If you just don’t want them to easily read the xml… don’t use a human readable format or obfuscate it (save it as base64 encoded for example) .

If you don’t want them editing it, include a checksum or hash to catch tampering.

If it is because the XML files add more functionality you want them to pay for, it’s a more difficult problem… but one you are ignoring on OSX because the files are no so obvious… In that case maybe some kind of license key for additional features solution might be workable

Add all the files to the resource section of the executable and have your program call them when needed.
I do this with my Programs developed in Delphi Rad XE. I do not use Xojo on Windows.

This is an easier way, append the data to the end of the executable, then calculate the offset
to read the different files. Only problem with this method is Anti-Virus software could get triggered.

I guess nobody is understanding the issue. In OSX I can dynamically determine the “name” of each of the resource files… in WIndows I cannot… As I am designing this I am constantly adding to these XML files, as well as adding new whole files. For OSX I just drag it to the IDE and my code takes care of the rest automatically. So for OSX I am doing exactly what you said. But that is NOT possible for Windows, without hard-codng the name of each file before the app is compiled … (That is … NOT going with an external folder)

I wish to deploy “the app”… not “the app” and a ton of XML files (and yes I know Win requires the support DLL files)

Thanks… guess I’ll figure this one out my self…

Given the DDLs, which means either using an installer or having the user put the app FOLDER as a whole somewhere, I don’t understand why you are so against using a resource folder for windows… Which is why I was asking why , to see if i could think of different solution that would meet the requirement.

While I don’t know if it can be automated with IDE scripting, it is possible for you to write Xojo code that creates a textfile for a module or class that you can manually drag into the project that has the info you want. I’ve done it in the past.

I don’t want to have two different deployment mechanisms… or more accuratly two different BUILD methods…

Which I why I asked about a script that would be part of the build process but would scan my directory and write a method that would be included in a Windows build only. So that the XML files COULD be inside the EXE … a Windows build would refer to them by string names (which is where the prebuild script comes in), while OSX could refer to them the same way it is now

A technique I’ve used is to take your EXE, and then simply append a block of data to the EXE file - the format of the data block is up to you. Generally, this doesn’t affect the EXE at all : it still opens and runs. You do have to pay attention if you are using SignCode as that also modifies the EXE as well.