Skip to Main Content Skip to Search
Product Documentation

uigetdir - Open standard dialog box for selecting directory

Syntax

folder_name = uigetdir
folder_name = uigetdir(start_path)
folder_name = uigetdir(start_path,dialog_title)

Description

folder_name = uigetdir displays a modal dialog box enabling the user to navigate the folder hierarchy and select a folder or type the name of a folder. If the folder exists, uigetdir returns the selected path when the user clicks OK. If the user types the name of a folder that does not exist, uigetdir returns the name of the current folder. If the user clicks Cancel or closes the dialog window, uigetdir returns 0. On Microsoft Windows platforms, uigetdir opens a dialog box in the base folder (the Windows desktop) with the current folder selected.

folder_name = uigetdir(start_path) opens a dialog box with the folder specified by start_path selected. If start_path is a valid path, the dialog box opens in the specified folder. If start_path is an empty string ('') or is not a valid path, the dialog box opens in the current folder.

folder_name = uigetdir(start_path,dialog_title) opens a dialog box with the specified title. On Windows and UNIX platforms, the string replaces the default caption inside the dialog box for specifying instructions to the user. The default dialog_title is Select folder to Open.

On Windows platforms, you can click the New Folder button to add a new folder to the folder hierarchy displayed. You can also drag and drop existing directories into different folders.

On UNIX platforms, uigetdir opens a dialog box in the startup folder (the one you are in when you start MATLAB), with the current directory selected. The dialog_title string replaces the default title of the dialog box. The dialog box looks like the one shown in the following figure.

On Mac platforms, uigetdir opens a dialog box in the startup folder (the one you are in when you start MATLAB), with the current directory selected. The dialog box is like the one shown in the following figure.

The pwd and cd functions return the name of the current folder.

Examples

The following statement displays directories on the C: drive.

dname = uigetdir('C:\');

The dialog box displays as follows (on Windows).

Selecting the directory Desktop, as shown in the figure, and clicking OK, uigetdir returns

dname =
C:\WINNT\Profiles\All Users\Desktop
 

The following statement uses the matlabroot command to display the MATLAB root directory in the dialog box:

uigetdir(matlabroot,'MATLAB Root Directory')

Selecting the directory MATLAB6.5/notebook/pc, as shown in the figure, returns a string like

C:\MATLAB6.5\notebook\pc

assuming that MATLAB is installed on drive C:\.

See Also

uigetfile | uiputfile

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS