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.
dim id_dir as Folderitem = GetFolderItem(yourstring)
Sorry Axel but I can’t make it work. It opens with whatever was the last folder selected - not the one in the path
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 NOT Selected")
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:
an answer on the NUG was:
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
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
3.Otherwise, if lpstrInitialDir is not NULL, it specifies the initial
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
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.
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