From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Shared Method

FolderItem.ShowSaveFileDialog(filter As String, defaultName As String) As FolderItem

New in 2019r2

Supported on Desktop.

Used to present the standard Save As dialog box to the user and return a folderitem representing the file to be created.


result=Folderitem.ShowSaveFileDialog(filter, default file name)

Part Type Description
result FolderItem Represents the file the user wants to create.
filter String The file type extensions to be assigned to the file, as defined in the File Type Sets Editor or via the FileType class.
defaultFileName String The name that should appear by default in the Save As dialog box.


The ShowSaveFileDialog function displays the standard Save As file dialog box, allowing the user to choose a location and enter a name for the file to be saved. The SaveAsDialog class provides the same functionality but allows for customization.

The ShowSaveFileDialog function does not create the file. It returns a FolderItem that represents the potential file. To create the actual file, you will need to call or Create shared method for TextOutputStream or the Create shared method of the BinaryStream.

The filter should either be an empty string or the name of a file type as defined in the File Type Sets Editor or via the FileType class.

On macOS 10.11 through 10.15, a Hide Filename Extension checkbox appears in the save-file dialog. The FolderItem returned has its ExtensionVisible property set according to the user's use of this checkbox.


This example displays the save as file dialog box. The File Type referred to by ShowSaveFileDialog declares the common file type "text/plain", which you will first want to add to your project using the File Type Group Editor.

A text file is then created and the text properties of three TextFields are written to the new file. Finally the file is closed.

Var f As FolderItem
Var fileStream As TextOutputStream
f = FolderItem.ShowSaveFileDialog(FileTypeGroup1.Text.Extensions, "MyInfo.txt")
If f <> Nil Then
fileStream = TextOutputStream.Create(f)
End If

See Also

FolderItem.ShowOpenFileDialog, FolderItem.ShowSelectFolderDialog functions; FileType, FolderItem, FolderItemDialog, SaveAsDialog classes.