GetOpenFolderItem Function

Used to access a document or application selected by the user via the standard open-file dialog box.

Syntax
result = GetOpenFolderItem( filter )

Parameters
filter | String | Semi-colon separated list of file types the user can open. The file types must be defined as REALbasic file types, either in the IDE in a File Types Set or with the FileType class.

Return Value
Result | FolderItem | Represents the file that was opened by the user. Result will be Nil if the user clicked the Cancel button.

# Notes

The GetOpenFolderItem function displays the standard open-file dialog box for the platform on which the REALbasic application is running. The FolderItemDialog class has the same purpose but allows for some customization.

The filter parameter is used to limit the types of files that the user can open to one or more of the file types defined via the FileType class or in the File Type Sets Editor in the IDE. The filter is a semi-colon separated list of file type names. For example, if you wanted the user to be able to open only text files and postscript files when making a particular call to the GetOpenFolderItem function, you would define two file types using either the File Type Sets Editor or the FileType class. You would then pass "application/text; application/postscript" (or the name you chose) as the filter to the GetOpenFolderItem function.

Only files whose type matches one of the file types passed in the filter will be displayed in the open file dialog box. If you want to display all files, you will need to add a file type to the project that uses "????" as its Macintosh Type.

The GetOpenFolderItem function returns a FolderItem that represents the file the user selected. You can then use the FolderItem to access various data about the file such as its name, full path, etc. See the FolderItem class for more information.

If the user clicks the Cancel button in the open file dialog box, the FolderItem will be Nil. You can test for this by comparing the FolderItem with the Nil value. Accessing a Nil FolderItem will cause a NilObjectException error.

# Examples

This example illustrates how to use the FileType class do specify the types of files that can be opened by GetOpenFolderItem.

Dim TextTypes as New FileType
Dim ImageTypes as New FileType
TextTypes.Name= "Text Files"
TextTypes.Extensions=".txt;.rtf;.doc"
ImageTypes.Name= "Image Files"
ImageTypes.Extensions = ".bmp;.jpg;.gif"
Dim f as FolderItem = GetOpenFolderItem(textTypes + ImageTypes)
If f <> Nil then
MsgBox f.AbsolutePath
End if

# See Also

GetSaveFolderItem, SelectFolder functions; FileType, FolderItem, FolderItemDialog classes.