FileNameSetter

FileNameSetter[name]
represents a file name setter which displays as a Browse button and when clicked brings up a system file opening dialog, starting from the location corresponding to name.

FileNameSetter[Dynamic[name]]
uses the dynamically updated current value of name, with the value of name being reset if a different file is chosen.

FileNameSetter[name, "Save"]
brings up a file saving dialog.

FileNameSetter[name, "spec", {"type1"->{"patt11", "patt12", ...}, "type2"->{...}, ...}]
looks for files of types with names matching the file patterns .

Details and OptionsDetails and Options

  • In FileNameSetter[name, "spec"] possible specifications of dialogs to use are:
  • "Open"file opening dialog (default)
    "OpenList"multiple file opening dialog
    "Save"file saving dialog
    "Directory"directory picking dialog
  • In FileNameSetter[name, "spec"], name is normally a single complete file name string.
  • In FileNameSetter[name, "OpenList"], name is always a list of file name strings.
  • FileNameSetter[name, "Save"] generates a warning if the file picked already exists.
  • If the file browser dialog is closed without choosing a file name, FileNameSetter leaves name unchanged.
  • FileNameSetter["", ...] uses no initial file name.
  • If no name is given that determines a valid directory, FileNameSetter uses as a default $UserDocumentsDirectory.
  • If no file type specification is given, the file browser dialog will list files of all types.
  • The give the names of filters to be listed in the file browser, and to be used for picking out files whose names match the file patterns specified.
  • The following options can be given:
  • AppearanceAutomaticthe appearance of the file name setter
    BaseStyle{}base style specifications for the setter
    EnabledAutomaticwhether the setter is enabled, or grayed out
    ImageMargins0margins around the displayed setter
    ImageSizeAutomaticoverall size of the displayed setter
    WindowTitleAutomaticthe title of the browser window
  • With the setting Appearance->"form", the string will be used in place of .
  • Other expressions given as settings for Appearance are used literally as the appearance of the unclicked FileNameSetter.
  • FileNameSetter is intended primarily for use with local kernels.
  • File names in FileNameSetter use the pathname separator appropriate for your computer system.
  • FileNameSetter[] is equivalent to FileNameSetter["", "Open"].
  • Setting can be used to find the file name specified by FileNameSetter.
  • The settings for BaseStyle are appended to the default style typically given by the style in the current stylesheet.

ExamplesExamplesopen allclose all

Basic Examples (4)Basic Examples (4)

Assign the full path of a file to a variable:

In[1]:=
Click for copyable input
Out[1]=

Assign the full path of multiple files to a variable:

In[1]:=
Click for copyable input
Out[1]=

Assign the full path of a new file without actually creating it:

In[1]:=
Click for copyable input
Out[1]=

Assign the full path of a directory to a variable:

In[1]:=
Click for copyable input
Out[1]=
New in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »