Following method I use in XOJO 2018r4 to return the folder in which the debugbuild run
Var f As FolderItem = GetFolderItem("")
#If DebugBuild Then f = f.Parent
Return f
In XOJO 2019r31 (API2) GetFolderItem is deprecated.
In the doc they say : please ues FolderItem.Constructor as a replacement.
The example in the API2 doc does not has any solution for me.
I’ve never liked the concept of GetFolderItem("") and have always used App.ExecutableFile.Parent instead to get the working folder. Using this method f = App.ExecutableFile.Parent.Child("Names") works and to me is more obvious/readable.
WOW have I been wrong for the last 3 years programming in XOJO ???
I thought that this method returned me the path for my debugfolder
Var f As FolderItem = GetFolderItem("")
#If DebugBuild Then f = f.Parent
Return f
results in f.NativePath = D:\XOJO-Projects\XOJO_2019r31\MMLite\00 MMLite\
This is NOT the correct path for my debugfolder
Var f As New FolderItem("")
#If DebugBuild Then f = App.ExecutableFile.Parent
Return f
results in f.NativePath = D:\XOJO-Projects\XOJO_2019r31\MMLite\00 MMLite\DebugMMLite\
This likes more correct to me
How come that it worked with the first code too ?
The folders necessary for my program are still in the first folder, and it would even work without the copyfiles in Build Settings I think.
Those 2 sets of code have different purposes. If you just want the debug folder - the folder where your app is currently running - the following should be equivalent (on Windows at least):
GetFolderItem("")
New FolderItem("")
App.ExecutableFile.Parent
This code
Var f As FolderItem = GetFolderItem("")
#If DebugBuild Then f = f.Parent
Return f
is intended to get the folder where the project resides, not where the debug folder is. This became necessary when the debug location was changed to be a subfolder of the project folder.