FolderItem, OpenDialog, and strings

I’m having a helluva time trying to get OpenDialog’s InitalDirectory to target what I want. Every example in the docs for opendialog show no means of targeting a folder other than using SpecialFolder, which isn’t what I’m looking for. I can’t use a string, and defining the pathtype is no help either. My app saves the user’s home folder path (ie: /home/bill) and a folder path containing certain config files which need to be opened for editing (which could be anywhere the user decided to put them). I’d like to be able to have opendialog target that folder, but I’ve fried my brain trying.
Can any of you smarter-than-me people please tell me how to do this?

InitialDirectory is a FolderItem

If you have a string containing the path to where you want the dialog to use as the initial directory you can use GetFolderItem with the path and a pathtype (probably of pathtypeabsolute) to get the folderitem. Then use that with OpenDialog.

ie/

dim path as string // this contains the string representing the path you want to use as initialdirectory
dim initialDir as FolderItem = GetFolderItem(path, FolderItem.PathTypeAbsolute)

and then you can use this folderitem with OpenDialog.

Hope that helps.

Thanks, Jason. I’ll give that a try and post back. :slight_smile:

That opens my user folder (/home/bill), not the path specified (/home/bill/ovpn). I have verified that the path is correct and available.
Even if I take the path from a textarea showing the correct path, it still doesn’t work.
Here’s what I’ve got:

[code]Dim dlg as OpenDialog
Dim f1 as FolderItem

dim path as string // this contains the string representing the path you want to use as initialdirectory
path = app.opath // this is a property to hold the path of user’s *.ovpn config files
dim initialDir as FolderItem = GetFolderItem(path, FolderItem.PathTypeAbsolute)

dlg=New OpenDialog
dlg.InitialDirectory=initialDir

dlg.Title=“Select your .ovpn file”
f1=dlg.ShowModal()
editovpn.text = dlg.result.NativePath[/code]
Can you please tell me what I’m doing wrong?

Nevermind, I solved it. /home/bill/ovpn was missing a trailing slash. Thank you so much for the help! :slight_smile: