Argv[0]?

I tried using this code to get the path to the executable.
It works if the application is Launched from the folder that contains the executable but does not work when the application is launched from a different directory using a path to the executable.

Current working directory (depends on the location of the application). When run from Xojo, it is the path to Xojo. In a built app, it is the path to the built app.

[code] Dim f As FolderItem
f = SpecialFolder.CurrentWorkingDirectory

respath = f.ShellPath + “/” + “myResource/”

If f <> Nil Then
System.DebugLog("This is the path to my: " + respath)
Else
System.DebugLog(“Unable to get current working directory.”)
End If
[/code]
Basically it is what it says it is… the current working directort.
The directory from which the application was launched from, but it is not the path to the application.

I have some resources and I need the path to them which is relative to the application executable.
I can’t seen to find this special folder in the list of special folders.

dim f as FolderItem = app.ExecutableFile

snap

Documentation is … slightly… misleading. :slight_smile:

You could also use something like:

GetFolderItem("Resources")

In what way?

 In a built app, it is the path to the built app.

but then… this is a build app run from the command line.

[quote=268855:@Brian O’Brien] In a built app, it is the path to the built app.
but then… this is a build app run from the command line.[/quote]

Ah, so it’s not the documentation on Application.ExecutableFile you found misleading but rather the SpecialFolder.CurrentWorkingDirectory documentation?

Yes, but just slightly. Careful reading is not my best point apparently. :wink:

I’d agree that it’s misleading. Could you file a bug report against the docs and mention what would have been a better explanation, in your eyes?