FolderItemDialog.InitalDirectory Question

I have a window which is displaying information from a SQLite record. One of the fields is a path to a folder of images but does NOT specify a particular image - just the folder where several images are located.

I want to dialog to open with the folder specified in the path which is just a text/string field. Apparently the InitialDirectory property wants a FolderItem as the InitialDirectory.

If I just use GetFolderItem, I don’t get a dialog.

How do I convert the path as a string so that it can be used as the initial directory. Or how else do I indicate where I want the dialog to start.

thanks guys.

dim id_dir as Folderitem = GetFolderItem(yourstring)
dlg.InitialDirectory=id_dir

Sorry Axel but I can’t make it work. It opens with whatever was the last folder selected - not the one in the path

[code]
Dim fImage As FolderItem
dim fFolder As FolderItem
Dim dlgGetImageFile As New SelectFolderDialog

	fFolder = GetFolderItem(tfPath.Text)
	
	dlgGetImageFile.ActionButtonCaption = "Select"
	dlgGetImageFile.Title = "Select Image "
	dlgGetImageFile.InitialDirectory = fFolder
	
	fImage = dlgGetImageFile.ShowModal
	If fImage <> Nil Then
			MsgBox("Image Selected")
	Else
			MsgBox("Image NOT Selected")
	End If
	
	
	Return True[/code]

Also added NEW to the dims

maybe you could add pathtype

fFolder = GetFolderItem(tfPath.Text, FolderItem.PathTypeNative) - if it is native path

Is this occuring in an app built for windows?
if yes, then this might be a “feature” (which has been introduced in Windows 7)

we’ve been asking ourselves the same in 2010:
<https://xojo.com/issue/10994>

an answer on the NUG was:

[code]Message: 18
Date: Fri, 8 Jan 2010 17:14:23 +0100
From: “Matthias Eberhardt”
Subject: AW: OpenDialog.InitialDirectory and Windows 7
To: “‘REALbasic NUG’”

the OpenDialog.InitialDirectory maps to lpstrInitialDir of the Common Dialog
API and the behaviour changed with Windows 7. From the Documentation (see
http://msdn.microsoft.com/en-us/library/ms646839(VS.85).aspx )

1.If lpstrInitialDir has the same value as was passed the first time the
application used an Open or Save As dialog box, the path most recently
selected by the user is used as the initial directory.
2.Otherwise, if lpstrFile contains a path, that path is the initial
directory.
3.Otherwise, if lpstrInitialDir is not NULL, it specifies the initial
directory.
4.If lpstrInitialDir is NULL and the current directory contains any files of
the specified filter types, the initial directory is the current directory.
5.Otherwise, the initial directory is the personal files directory of the
current user.
6.Otherwise, the initial directory is the Desktop folder.

Number 1 is what you’ve observed.[/code]

Per Axel, I added FolderItem.PathTypeNative and it work well.

Thanks Axel

Did not work for me. Any news about ths issue?

are you sure you are giving it a valid path name that matches the supplied pathtype?

post your code