pub struct FileDialogBuilder(_);
desktop
and crate feature dialog
only.Expand description
The file dialog builder.
Constructs file picker dialogs that can select single/multiple files or directories.
Implementations§
source§impl FileDialogBuilder
impl FileDialogBuilder
sourcepub fn add_filter(self, name: impl AsRef<str>, extensions: &[&str]) -> Self
pub fn add_filter(self, name: impl AsRef<str>, extensions: &[&str]) -> Self
Add file extension filter. Takes in the name of the filter, and list of extensions
sourcepub fn set_directory<P: AsRef<Path>>(self, directory: P) -> Self
pub fn set_directory<P: AsRef<Path>>(self, directory: P) -> Self
Set starting directory of the dialog.
sourcepub fn set_file_name(self, file_name: &str) -> Self
pub fn set_file_name(self, file_name: &str) -> Self
Set starting file name of the dialog.
sourcepub fn set_parent<W: HasRawWindowHandle>(self, parent: &W) -> Self
pub fn set_parent<W: HasRawWindowHandle>(self, parent: &W) -> Self
Sets the parent window of the dialog.
source§impl FileDialogBuilder
impl FileDialogBuilder
sourcepub fn pick_file(self) -> Option<PathBuf>
pub fn pick_file(self) -> Option<PathBuf>
Shows the dialog to select a single file. This is a blocking operation, and should NOT be used when running on the main thread context.
Examples
use tauri::api::dialog::blocking::FileDialogBuilder;
#[tauri::command]
async fn my_command() {
let file_path = FileDialogBuilder::new().pick_file();
// do something with the optional file path here
// the file path is `None` if the user closed the dialog
}
sourcepub fn pick_files(self) -> Option<Vec<PathBuf>>
pub fn pick_files(self) -> Option<Vec<PathBuf>>
Shows the dialog to select multiple files. This is a blocking operation, and should NOT be used when running on the main thread context.
Examples
use tauri::api::dialog::blocking::FileDialogBuilder;
#[tauri::command]
async fn my_command() {
let file_path = FileDialogBuilder::new().pick_files();
// do something with the optional file paths here
// the file paths value is `None` if the user closed the dialog
}
sourcepub fn pick_folder(self) -> Option<PathBuf>
pub fn pick_folder(self) -> Option<PathBuf>
Shows the dialog to select a single folder. This is a blocking operation, and should NOT be used when running on the main thread context.
Examples
use tauri::api::dialog::blocking::FileDialogBuilder;
#[tauri::command]
async fn my_command() {
let folder_path = FileDialogBuilder::new().pick_folder();
// do something with the optional folder path here
// the folder path is `None` if the user closed the dialog
}
sourcepub fn pick_folders(self) -> Option<Vec<PathBuf>>
pub fn pick_folders(self) -> Option<Vec<PathBuf>>
Shows the dialog to select multiple folders. This is a blocking operation, and should NOT be used when running on the main thread context.
Examples
use tauri::api::dialog::blocking::FileDialogBuilder;
#[tauri::command]
async fn my_command() {
let folder_paths = FileDialogBuilder::new().pick_folders();
// do something with the optional folder paths here
// the folder paths value is `None` if the user closed the dialog
}
sourcepub fn save_file(self) -> Option<PathBuf>
pub fn save_file(self) -> Option<PathBuf>
Shows the dialog to save a file. This is a blocking operation, and should NOT be used when running on the main thread context.
Examples
use tauri::api::dialog::blocking::FileDialogBuilder;
#[tauri::command]
async fn my_command() {
let file_path = FileDialogBuilder::new().save_file();
// do something with the optional file path here
// the file path is `None` if the user closed the dialog
}