Function Reference


FileSelectFolder

Initiates a Browse For Folder dialog.

FileSelectFolder ( "dialog text", "root dir" [, flag = 0 [, "initial dir" [, hwnd]]] )

Parameters

dialog text Text greeting in dialog.
root dir Root directory of GUI file tree. It limits a choice in the root folder. Use "" for Desktop to be root.
flag [optional]
    $FSF_CREATEBUTTON (1) = Show Create Folder Button (XP only)
    $FSF_NEWDIALOG (2) = Use New Dialog Style (XP only)
    $FSF_EDITCONTROL (4) = Show Edit Control (XP only)

Constants are defined in FileConstants.au3.
initial dir [optional] The full path of the folder you selected/highlighted when displaying dialogue (if it exists in the root folder). Default is blank ("").
hwnd [optional] The window handle to use as the parent for this dialog.

Return Value

Success: the full path of the folder chosen.
Failure: "" (empty string) and sets the @error flag to 1 if user cancels/closes the window.

Remarks

The root dir will be chosen if the initial dir (if given) does not exist.
A nonexistent root dir will also cause the Desktop folder to be root.
Special Windows folders (such as "My Documents") can be set as root by using the right CLSID detailed in the Appendix.
UNC paths are not supported. If you think that user's may choose files on a UNC path then the path needs to be mapped as a drive first.

The new vista+ dialog style is used if possible, regardless of the Use New Dialog Style flag. With the vista dialog style the edit control and create folder buttons are always shown, ignoring the flags parameter, and the dialog text parameter sets the title of the window.

Related

FileOpenDialog, FileSaveDialog

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
    Local Const $sMessage = "Select a folder"

    ; Display an open dialog to select a file.
    Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
    Else
        ; Display the selected folder.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)
    EndIf
EndFunc   ;==>Example