How to get OpenDialog SpecialFolder to Work

I have been unable to get the SpecialFolder option for an OpenDialog to work.
The following code is supposed to open the dialog up in the current executable’s folder.
No matter what, it always opens up in the root device directory.

  dlg=New OpenDialog
  dlg.Title="Select a JPEG or PNG image file"
  dlg.Filter=jpegType + pngType //Defined as file type in FileTypes1.
  dlg.InitialDirectory = SpecialFolder.CurrentWorkingDirectory
  f=dlg.ShowModal()

I’m running Xojo 2015 2.2 on MAC OS X Yosemite.

On OS X, CurrentWorkingDirectory is not where the application is. It is usually “/”, the root directory.

Opening files in the app’s directory is generally frowned upon. What are you trying to accomplish?

Try using GetFolderItem("") instead.

This application allows the user to use image and audio files. By opening up in the working directory I’m simply attempting to make it easier for the user to efficiently manage these in one location. The app is deployed in a directory with a “media” directory already existing. This way the user can move the app and all support files together.

Greg, thank you, I will try your suggestion.

Greg, your suggestion worked perfectly. I used GetFolderItem("").child(“media”) which did the trick.

What would be the equivalent on Windows 7 and 8?

[quote=199022:@Ola Olsson]I used GetFolderItem("").child(“media”) which did the trick.

What would be the equivalent on Windows 7 and 8?[/quote]

could be GetFolderItem("").Parent.child(“media”)

[quote=199022:@Ola Olsson]Greg, your suggestion worked perfectly. I used GetFolderItem("").child(“media”) which did the trick.

What would be the equivalent on Windows 7 and 8?[/quote]

If Media is created in the same folder as where the executable is, that will work the same.