If what you’re looking for is a file next to the application then it is quite possibly in a different location on OS X and Windows
Say you call your app “MyApp” and , for the sake of discussion, you put your app inside a directory on both OS X and Windows called MyApp.
So your “exe” is inside that directory
And we’ll assume you put your app in the “recommended location for applications” on each
On Windows you would then put your app in a directory, MyApp, in C:\Program Files
Your app then is C:\Program Files\MyApp\MyApp.exe
Your data file, called MyData, would be at C:\Program Files\MyApp\MyData
On OS X then you would put your app in /Applications/MyApp/
But in this case because of how OS X package applications your executable is actually in /Applications/MyApp/MyApp.app/Content/MacOSX/MyApp
(end users perceive /Applications/MyApp/MyApp.app as the runnable executable though)
And your data file NEXT TO the “exe”, or what users perceive as the exe, would be /Applications/MyApp/MyData
Now people can, and do, put applications in all kinds of places and not always in the recommended spot.
So to get the file “next to” your app on each platform regardless of where the application is you will need some code like
dim f as folderItem = app.ExecutableFile
On Windows now you have (for our example, f referring to C:\Program Files\MyApp\MyApp.exe) and the data file next to the exe is
dim nextToExe as folderitem = app.executableFile.Parent.child("MyData")
- parent is C:\\Program Files\\MyApp
- child is C:\\Program Files\\MyApp\\MyData
But, as you can see from the above this won’t work on OS X because
dim f as folderItem = app.ExecutableFile
f refers to /Applications/MyApp/MyApp.app/Content/MacOSX/MyApp
dim nextToExe as folderitem = app.executableFile.Parent.child(“MyData”)
- parent is /Applications/MyApp/MyApp.app/Content/MacOSX
- child is /Applications/MyApp/MyApp.app/Content/MacOSX/MyData
but really your data file is at /Applications/MyApp/MyData
To make this work x-platform you need something like
dim f as folderItem = app.ExecutableFile
dim nextToExe as folderitem
#if TargetMacOS
nextToExe = app.executableFile.Parent.Parent.Parent.Parent.child("MyData")
#else
nextToExe = app.executableFile.Parent.child("MyData")
#endif
And now this will find MyData beside the application executable on both platforms even if the application is NOT in the recommended location