pub struct FileDialogBuilder(_);
Available on crate feature dialog only.
Expand description

The file dialog builder.

Constructs file picker dialogs that can select single/multiple files or directories.

Implementations

Gets the default file dialog builder.

Add file extension filter. Takes in the name of the filter, and list of extensions

Set starting directory of the dialog.

Set starting file name of the dialog.

Sets the parent window of the dialog.

Set the title of the dialog.

Shows the dialog to select a single file. This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.

For usage in other contexts such as commands, prefer Self::pick_file.

Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
  .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
  .expect("failed to build tauri app")
  .run(|_app, _event| {
    FileDialogBuilder::new().pick_file(|file_path| {
      // do something with the optional file path here
      // the file path is `None` if the user closed the dialog
    })
  })

Shows the dialog to select multiple files. This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.

Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
  .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
  .expect("failed to build tauri app")
  .run(|_app, _event| {
    FileDialogBuilder::new().pick_files(|file_paths| {
      // do something with the optional file paths here
      // the file paths value is `None` if the user closed the dialog
    })
  })

Shows the dialog to select a single folder. This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.

Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
  .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
  .expect("failed to build tauri app")
  .run(|_app, _event| {
    FileDialogBuilder::new().pick_folder(|folder_path| {
      // do something with the optional folder path here
      // the folder path is `None` if the user closed the dialog
    })
  })

Shows the dialog to select multiple folders. This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.

Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
  .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
  .expect("failed to build tauri app")
  .run(|_app, _event| {
    FileDialogBuilder::new().pick_folders(|file_paths| {
      // do something with the optional folder paths here
      // the folder paths value is `None` if the user closed the dialog
    })
  })

Shows the dialog to save a file.

This is not a blocking operation, and should be used when running on the main thread to avoid deadlocks with the event loop.

Examples
use tauri::api::dialog::FileDialogBuilder;
tauri::Builder::default()
  .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
  .expect("failed to build tauri app")
  .run(|_app, _event| {
    FileDialogBuilder::new().save_file(|file_path| {
      // do something with the optional file path here
      // the file path is `None` if the user closed the dialog
    })
  })

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.