chdir in Xojo?

Is there an equivalent to chdir command in Xojo?
I could not find a reference here or in the language reference.


No, not in the VB sense. Xojo doesn’t really use file paths like that. Just create a FolderItem pointing to the path you want and then use Child or Parent to go from there.


No, because there isn’t a default folder. You can’t tell Xojo “save this file” and expect the file to be saved in a certain folder, you need to specify “save this file in myFolder”. It’s a different way of working.

Have a look at the folderitem class.


SetCurrentWorkingDirectoryMBS in MBS Plugin would do it:

Thanks looks like that will help.

Vern, would you mind explaining what you need chdir for?

Maybe we can tell you the Xojo way to accomplish what you need.


Great idea Julian thanks.
I want the program to check for or create if they do not exist some folders in the Documents Folder. Currently the VB6 version puts the folders I want under the install folder. Not generally considered a good idea but seems to work.
Like so; Program Files(86)\Central Command\ then under Central Command are the folders CWT2 and NewTurn There could be more folders starting with the letters CW each one having text files a database and some additional folders. The NewTurn folder will only contain text files.

So what the program should do is check for the existence of the Central Command folder in the Documents folder. If it does not exist them create it. Then create the NewTurn folder under the Central Command folder. In the case where Central Command does exist check for NewTurn and/or create it. Then check for folders in Central Command that start with the letters “CW” and depending on what is found take certain actions.

Any ideas suggestions or pointers to documentation would be greatly appreciated. Thanks in advance.

dim f as folderitem
f=specialfolder.documents.child("name to check for")
if f.exists=false then f.createasfolder()

you should be able to figure out the rest…

and the Language Reference is your friend

May I suggest instead you place your files inside a folder within the ApplicationData folder. That is the recommended way.


It depends on whether the files should be visible to the user. Files you want the user to be able to interact with, whether that be naming the document when it is saved or even opening it with a different app, go in Documents. Files that the user shouldn’t mess with go in ApplicationData.

Ie., does the user care about the file, or just about the app?

Thanks you were all very helpful. Problem solved.