xtd - Reference Guide
0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
|
#include <file_dialog.h>
Displays a dialog box from which the user can select a file.
Path or program category | Class and members to use |
---|---|
Standard Windows paths, such as Program Files, MyDocuments, the Desktop and so on | The xtd::environment class is the most complete source for these, either through its static methods, such as system_directory, or through the get_folder_path method, using one of the environment::special_folder enumerated values. |
Paths related to the current application | The application class has static members to obtain certain paths, such as startup_path, executable_path, local_user_app_data_path, and common_app_data_path. The get_temp_path method of the xtd::io::path returns the path of the temporary folder. The get_current_directory method of the xtd::io::directory class returns the application's current executing directory. The root_directory property of the drive_info class represents the specified drive's root directory. |
Paths stored as application settings | Access the corresponding applications settings property of the wrapper class derived from application_settings_base. For more information, see application settings for Windows Forms. |
Registry storage | Some applications store directory information in the registry. The Application class has the common_ app_data_path and local_user_app_data_path properties that resolve to a registry_key value. |
ClickOnce applications | For click_once applications, use application class members such as user_app_data_path, which will return a pointer to the click_once data directory. For more information, see accessing local and remote data in click_once applications. |
International applications | For international applications, retrieve the relative path portion from a string resource in your application by using the xtd::resources::resource_reader class. For more information about globalization and localization |
Inherits xtd::forms::common_dialog.
Inherited by xtd::forms::open_file_dialog, and xtd::forms::save_file_dialog.
Public Member Functions | |
file_dialog ()=default | |
Initializes a new instance of the common_dialog class. | |
virtual bool | add_extension () const |
Gets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension. | |
virtual file_dialog & | add_extension (bool value) |
Sets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension. | |
virtual bool | auto_upgrade_enabled () const |
Gets a value indicating whether this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista. | |
virtual file_dialog & | auto_upgrade_enabled (bool value) |
Sets a value indicating whether this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista. | |
virtual bool | check_file_exists () const |
Gets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist. | |
virtual file_dialog & | check_file_exists (bool value) |
Sets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist. | |
virtual bool | check_path_exists () const |
Gets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist. | |
virtual file_dialog & | check_path_exists (bool value) |
Sets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist. | |
virtual const xtd::ustring & | default_ext () const |
Gets the default file name extension. | |
virtual file_dialog & | default_ext (const xtd::ustring &value) |
Sets the default file name extension. | |
virtual bool | dereference_link () const |
Gets a value indicating whether the dialog box returns the location of the file referenced by the shortcut or whether it returns the location of the shortcut (.lnk). | |
virtual file_dialog & | dereference_link (bool value) |
Sets a value indicating whether the dialog box returns the location of the file referenced by the shortcut or whether it returns the location of the shortcut (.lnk). | |
virtual const xtd::ustring & | file_name () const |
Gets a string containing the file name selected in the file dialog box. | |
virtual file_dialog & | file_name (const xtd::ustring &value) |
Sets a string containing the file name selected in the file dialog box. | |
virtual const std::vector< xtd::ustring > | file_names () const |
Gets the file names of all selected files in the dialog box. | |
virtual const xtd::ustring & | filter () const |
Gets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box. | |
virtual file_dialog & | filter (const xtd::ustring &value) |
Sets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box. | |
virtual size_t | filter_index () const |
Gets the index of the filter currently selected in the file dialog box. | |
virtual file_dialog & | filter_index (size_t value) |
Sets the index of the filter currently selected in the file dialog box. | |
virtual const xtd::ustring & | initial_directory () const |
Gets the initial directory displayed by the file dialog box. | |
virtual file_dialog & | initial_directory (const xtd::ustring &value) |
Sets the initial directory displayed by the file dialog box. | |
size_t | options () const |
Gets values to initialize the file_dialog. | |
void | reset () override |
Resets all properties to their default values. | |
virtual bool | restore_directory () const |
Gets a value indicating whether the dialog box restores the directory to the previously selected directory before closing. | |
virtual file_dialog & | restore_directory (bool value) |
Sets a value indicating whether the dialog box restores the directory to the previously selected directory before closing. | |
virtual bool | show_help () const |
Gets a value indicating whether the Help button is displayed in the file dialog box. | |
virtual file_dialog & | show_help (bool value) |
Sets a value indicating whether the Help button is displayed in the file dialog box. | |
virtual bool | show_hidden_files () const |
Gets a value indicating whether hidden files are displayed in the file dialog box. | |
virtual file_dialog & | show_hidden_files (bool value) |
Sets a value indicating whether hidden files are displayed in the file dialog box. | |
virtual bool | show_preview () const |
Gets a value indicating whether preview file is displayed in the file dialog box. | |
virtual file_dialog & | show_preview (bool value) |
Sets a value indicating whether preview file is displayed in the file dialog box. | |
virtual bool | support_multi_dotted_extensions () const |
Gets whether the dialog box supports displaying and saving files that have multiple file name extensions.Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions. | |
virtual file_dialog & | support_multi_dotted_extensions (bool value) |
Sets whether the dialog box supports displaying and saving files that have multiple file name extensions.Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions. | |
virtual const xtd::ustring & | title () const |
Gets the file dialog box title. | |
virtual file_dialog & | title (const xtd::ustring &value) |
Sets the file dialog box title. | |
xtd::ustring | to_string () const noexcept override |
Provides a string version of this object. | |
virtual bool | validate_names () const |
Gets a value indicating whether the dialog box accepts only valid file names. | |
virtual file_dialog & | validate_names (bool value) |
Gets a value indicating whether the dialog box accepts only valid file names. | |
Public Member Functions inherited from xtd::forms::common_dialog | |
common_dialog ()=default | |
Initializes a new instance of the common_dialog class. | |
xtd::forms::dialog_result | dialog_result () const |
Get async dialog_result result after dialog box is closing. | |
virtual void | reset ()=0 |
When overridden in a derived class, resets the properties of a common dialog box to their default values. | |
xtd::forms::dialog_result | show_dialog () |
Runs a common dialog box with a default owner. | |
xtd::forms::dialog_result | show_dialog (const iwin32_window &owner) |
Runs a common dialog box with the specified owner. | |
void | show_sheet (const iwin32_window &owner) |
Runs a common dialog box with the specified owner. | |
xtd::forms::dialog_result | show_sheet_dialog (const iwin32_window &owner) |
Runs a common dialog box with the specified owner. | |
std::any | tag () const |
Gets an object that contains data about the control. | |
common_dialog & | tag (const std::any &tag) |
Sets an object that contains data about the control. | |
Public Member Functions inherited from xtd::object | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual size_t | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
template<typename object_t > | |
std::unique_ptr< object_t > | memberwise_clone () const |
Gets the type of the current instance. | |
virtual xtd::ustring | to_string () const noexcept |
Returns a std::string that represents the current object. | |
Protected Member Functions | |
bool | run_dialog (intptr_t hwnd_owner) override |
Runs file dialog box. | |
void | run_sheet (intptr_t hwnd_owner) override |
Runs file dialog box in sheet mode. | |
Protected Member Functions inherited from xtd::forms::common_dialog | |
virtual void | on_dialog_closed (const dialog_closed_event_args &e) |
Raises the common_dialog::dialog_close event. | |
virtual void | on_help_request (help_event_args &e) |
Raises the common_dialog::help_request event. | |
virtual bool | run_dialog (intptr_t hwnd_owner)=0 |
When overridden in a derived class, specifies a common dialog box. | |
virtual void | run_sheet (intptr_t hwnd_owner)=0 |
When overridden in a derived class, specifies a common dialog box. | |
Protected Member Functions inherited from xtd::forms::component | |
component ()=default | |
Initialises a new instance of the component class. | |
virtual bool | can_raise_events () const |
Gets a value indicating whether the component can raise an event. | |
bool | design_mode () const |
Gets a value that indicates whether the component is currently in design mode. | |
Additional Inherited Members | |
Public Attributes inherited from xtd::forms::common_dialog | |
event< common_dialog, dialog_closed_event_handler > | dialog_closed |
Occurs when the user close a common dialog box with dialog close button or other dialog buttons. | |
event< common_dialog, help_event_handler > | help_request |
Occurs when the user clicks the Help button on a common dialog box. | |
Static Public Member Functions inherited from xtd::object | |
static bool | equals (const object &object_a, const object &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
static bool | reference_equals (const object &object_a, const object &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
|
default |
Initializes a new instance of the common_dialog class.
|
inlinevirtual |
Gets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension.
|
inlinevirtual |
Sets a value indicating whether the dialog box automatically adds an extension to a file name if the user omits the extension.
value | true if the dialog box adds an extension to a file name if the user omits the extension; otherwise, false. The default value is true. |
|
inlinevirtual |
Gets a value indicating whether this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista.
|
inlinevirtual |
Sets a value indicating whether this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista.
value | true if this file_dialog instance should automatically upgrade appearance and behavior when running on Windows Vista; otherwise, false. The default is true. |
|
inlinevirtual |
Gets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist.
|
inlinevirtual |
Sets a value indicating whether the dialog box displays a warning if the user specifies a file name that does not exist.
value | true if the dialog box displays a warning if the user specifies a file name that does not exist; otherwise, false. The default value is false. |
|
inlinevirtual |
Gets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist.
|
inlinevirtual |
Sets a value indicating whether the dialog box displays a warning if the user specifies a path that does not exist.
value | true if the dialog box displays a warning when the user specifies a path that does not exist; otherwise, false. The default value is true. |
|
inlinevirtual |
Gets the default file name extension.
|
inlinevirtual |
Sets the default file name extension.
value | The default file name extension. The returned string does not include the period. The default value is an empty string (""). |
|
inlinevirtual |
Gets a value indicating whether the dialog box returns the location of the file referenced by the shortcut or whether it returns the location of the shortcut (.lnk).
|
inlinevirtual |
Sets a value indicating whether the dialog box returns the location of the file referenced by the shortcut or whether it returns the location of the shortcut (.lnk).
value | true if the dialog box returns the location of the file referenced by the shortcut; otherwise, false. The default value is true. |
|
inlinevirtual |
Gets a string containing the file name selected in the file dialog box.
|
inlinevirtual |
Sets a string containing the file name selected in the file dialog box.
value | The file name selected in the file dialog box. The default value is an empty string (""). |
|
inlinevirtual |
Gets the file names of all selected files in the dialog box.
|
inlinevirtual |
Gets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box.
Text files (*.txt)|*.txt|All files (*.*)|*.*
Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*
|
inlinevirtual |
Sets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box.
value | The file filtering options available in the dialog box. |
Text files (*.txt)|*.txt|All files (*.*)|*.*
Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*
|
inlinevirtual |
Gets the index of the filter currently selected in the file dialog box.
|
inlinevirtual |
Sets the index of the filter currently selected in the file dialog box.
value | A value containing the index of the filter currently selected in the file dialog box. The default value is 1. |
|
inlinevirtual |
Gets the initial directory displayed by the file dialog box.
|
inlinevirtual |
Sets the initial directory displayed by the file dialog box.
value | The initial directory displayed by the file dialog box. The default is an empty string (""). |
|
inline |
Gets values to initialize the file_dialog.
|
overridevirtual |
Resets all properties to their default values.
Implements xtd::forms::common_dialog.
|
inlinevirtual |
Gets a value indicating whether the dialog box restores the directory to the previously selected directory before closing.
|
inlinevirtual |
Sets a value indicating whether the dialog box restores the directory to the previously selected directory before closing.
value | true if the dialog box restores the current directory to the previously selected directory if the user changed the directory while searching for files; otherwise, false. The default value is false. |
|
overrideprotectedvirtual |
Runs file dialog box.
hwnd_owner | A value that represents the window handle of the owner window for the common dialog box. |
Implements xtd::forms::common_dialog.
|
overrideprotectedvirtual |
Runs file dialog box in sheet mode.
hwnd_owner | A value that represents the window handle of the owner window for the common dialog box. |
Implements xtd::forms::common_dialog.
|
inlinevirtual |
Gets a value indicating whether the Help button is displayed in the file dialog box.
|
inlinevirtual |
Sets a value indicating whether the Help button is displayed in the file dialog box.
value | true if the dialog box includes a help button; otherwise, false. The default value is false. |
|
inlinevirtual |
Gets a value indicating whether hidden files are displayed in the file dialog box.
|
inlinevirtual |
Sets a value indicating whether hidden files are displayed in the file dialog box.
value | true if the dialog box includes hidden files; otherwise, false. The default value is false. |
|
inlinevirtual |
Gets a value indicating whether preview file is displayed in the file dialog box.
|
inlinevirtual |
Sets a value indicating whether preview file is displayed in the file dialog box.
value | true if the dialog box includes preview file; otherwise, false. The default value is false. |
|
inlinevirtual |
Gets whether the dialog box supports displaying and saving files that have multiple file name extensions.Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions.
|
inlinevirtual |
Sets whether the dialog box supports displaying and saving files that have multiple file name extensions.Gets or sets whether the dialog box supports displaying and saving files that have multiple file name extensions.
value | true if the dialog box supports multiple file name extensions; otherwise, false. The default is false. |
|
inlinevirtual |
Gets the file dialog box title.
|
inlinevirtual |
Sets the file dialog box title.
value | The file dialog box title. The default value is an empty string (""). |
|
inlineoverridevirtualnoexcept |
Provides a string version of this object.
Reimplemented from xtd::object.
|
inlinevirtual |
Gets a value indicating whether the dialog box accepts only valid file names.
|
inlinevirtual |
Gets a value indicating whether the dialog box accepts only valid file names.
value | true if the dialog box accepts only valid file names; otherwise, false. The default value is true. |