Initiates a Browse For Folder dialog.
FileSelectFolder ( "dialog text", "root dir" [, flag = 0 [, "initial dir" [, hwnd]]] )
|dialog text||Text greeting in dialog.|
|root dir||Root directory of GUI file tree - use to limit user choice. Setting "" uses Desktop - see remarks below.|
$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.|
|Success:||the full path of the folder chosen.|
|Failure:||"" (empty string) and sets the @error flag to 1 if user cancels/closes the window.|
Using a nonexistent root dir will also cause the Desktop folder to be used. Note that DeskTop is the root folder for the entire computer and is not the same as @DesktopDir, which is the current user desktop.
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.
#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