The following code example demonstrate the use of open_file_dialog dialog.
- Windows
-
- macOS
-
- Gnome
-
#include <xtd/xtd>
using namespace std;
class form1 : public form {
public:
form1() {
text("Open file dialog example");
open_file_dialog dialog;
dialog.initial_directory(!file_name.empty() ? io::path::get_directory_name(file_name) : environment::get_folder_path(environment::special_folder::desktop));
dialog.file_name(io::path::get_file_name(file_name));
dialog.filter("Text Files (*.txt)|*.txt|All Files (*.*)|*.*");
file_name = dialog.file_name();
label1.text(ustring::format("File = {}", file_name));
}
};
label1.parent(*this);
label1.text("File = ");
label1.auto_size(true);
label1.location({10, 40});
}
private:
label label1;
ustring file_name;
};
int main() {
application::run(form1());
}
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17