![]() |
xtd - Reference Guide
0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
|
#include <directory.h>
Exposes static methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.
Classes | |
class | directory_iterator |
Represent directory iterator used by xtd::io::directory. More... | |
class | file_iterator |
Represent file iterator used by xtd::io::directory. More... | |
class | file_system_entry_iterator |
Represent file system iterator used by xtd::io::directory. More... | |
Methods | |
static xtd::io::directory_info | create_directory (const xtd::ustring &path) |
Creates all directories and subdirectories in the specified path unless they already exist. More... | |
static xtd::io::directory::directory_iterator | enumerate_directories (const xtd::ustring &path) |
Returns an enumerable collection of directory full names in a specified path. More... | |
static xtd::io::directory::directory_iterator | enumerate_directories (const xtd::ustring &path, const xtd::ustring &search_pattern) |
Returns an enumerable collection of directory full names that match a search pattern in a specified path. More... | |
static xtd::io::directory::file_iterator | enumerate_files (const xtd::ustring &path) |
Returns an enumerable collection of full file names in a specified path. More... | |
static xtd::io::directory::file_iterator | enumerate_files (const xtd::ustring &path, const xtd::ustring &search_pattern) |
Returns an enumerable collection of full file names that match a search pattern in a specified path. More... | |
static xtd::io::directory::file_system_entry_iterator | enumerate_file_system_entries (const xtd::ustring &path) |
Returns an enumerable collection of file names and directory names in a specified path. More... | |
static xtd::io::directory::file_system_entry_iterator | enumerate_file_system_entries (const xtd::ustring &path, const xtd::ustring &search_pattern) |
Returns an enumerable collection of file names and directory names that match a search pattern in a specified path. More... | |
static bool | exists (const xtd::ustring &path) |
Determines whether the given path refers to an existing directory on disk. More... | |
static xtd::date_time | get_creation_time (const xtd::ustring &path) |
Gets the creation date and time of a directory. More... | |
static xtd::ustring | get_current_directory () |
Gets the current working directory of the application. More... | |
static std::vector< xtd::ustring > | get_directories (const xtd::ustring &path) |
Returns the names of subdirectories (including their paths) in the specified directory. More... | |
static std::vector< xtd::ustring > | get_directories (const xtd::ustring &path, const xtd::ustring &search_pattern) |
Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory. More... | |
static xtd::ustring | get_directory_root (const xtd::ustring &path) |
Returns the volume information, root information, or both for the specified path. More... | |
static std::vector< xtd::ustring > | get_files (const xtd::ustring &path) |
Returns the names of files (including their paths) in the specified directory. More... | |
static std::vector< xtd::ustring > | get_files (const xtd::ustring &path, const xtd::ustring &search_pattern) |
Returns the names of files (including their paths) that match the specified search pattern in the specified directory. More... | |
static std::vector< xtd::ustring > | get_file_system_entries (const xtd::ustring &path) |
Returns the names of all files and subdirectories in a specified path. More... | |
static std::vector< xtd::ustring > | get_file_system_entries (const xtd::ustring &path, const xtd::ustring &search_pattern) |
Returns an array of file names and directory names that match a search pattern in a specified path. More... | |
static xtd::date_time | get_last_access_time (const xtd::ustring &path) |
Returns the date and time the specified file or directory was last accessed. More... | |
static xtd::date_time | get_last_write_time (const xtd::ustring &path) |
Returns the date and time the specified file or directory was last written to. More... | |
static std::vector< xtd::ustring > | get_logical_drives () |
Retrieves the names of the logical drives on this computer in the form "<drive letter>:\". More... | |
static xtd::io::directory_info | get_parent (const xtd::ustring &path) |
Retrieves the parent directory of the specified path, including both absolute and relative paths. More... | |
static void | move (const xtd::ustring &source_dir_name, const xtd::ustring &dest_dir_name) |
Moves a file or a directory and its contents to a new location. More... | |
static void | remove (const xtd::ustring &path) |
Deletes an empty directory from a specified path. More... | |
static void | remove (const xtd::ustring &path, bool recursive) |
Deletes the specified directory and, if indicated, any subdirectories and files in the directory. More... | |
static void | set_creation_time (const xtd::ustring &path, const xtd::date_time &creation_time) |
Sets the creation date and time for the specified file or directory. More... | |
static void | set_creation_time (const xtd::ustring &path, time_t creation_time) |
Sets the creation date and time for the specified file or directory. More... | |
static void | set_current_directory (const xtd::ustring &path) |
Sets the application's current working directory to the specified directory. More... | |
static void | set_last_access_time (const xtd::ustring &path, const xtd::date_time &last_access_time) |
Sets the date and time the specified file or directory was last accessed. More... | |
static void | set_last_write_time (const xtd::ustring &path, const xtd::date_time &last_write_time) |
Sets the date and time a directory was last written to. More... | |
|
static |
Creates all directories and subdirectories in the specified path unless they already exist.
path | The directory to create. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns an enumerable collection of directory full names in a specified path.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns an enumerable collection of directory full names that match a search pattern in a specified path.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
search_pattern | The search string to match against the names of directories in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
|
static |
Returns an enumerable collection of file names and directory names in a specified path.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns an enumerable collection of file names and directory names that match a search pattern in a specified path.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
serach_pattern | The search string to match against the names of file-system entries in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
|
static |
Returns an enumerable collection of full file names in a specified path.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns an enumerable collection of full file names that match a search pattern in a specified path.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
search_pattern | The search string to match against the names of files in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
|
static |
Determines whether the given path refers to an existing directory on disk.
path | The path to test. |
|
static |
Gets the creation date and time of a directory.
path | The path of the directory. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Gets the current working directory of the application.
xtd::unauthorized_access_exception | The caller does not have the required permission. |
xtd::not_supported_exception | The operating system does not have current directory functionality. |
|
static |
Returns the names of subdirectories (including their paths) in the specified directory.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
search_pattern | The search string to match against the names of subdirectories in path. This parameter can contain a combination of valid literal and wildcard characters, but it doesn't support regular expressions. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
|
static |
Returns the volume information, root information, or both for the specified path.
path | The path of a file or directory. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns the names of all files and subdirectories in a specified path.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns an array of file names and directory names that match a search pattern in a specified path.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
serach_pattern | The search string to match against the names of file and directories in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
|
static |
Returns the names of files (including their paths) in the specified directory.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns the names of files (including their paths) that match the specified search pattern in the specified directory.
path | The relative or absolute path to the directory to search. This string is not case-sensitive. |
search_pattern | The search string to match against the names of files in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
|
static |
Returns the date and time the specified file or directory was last accessed.
path | The file or directory for which to obtain access date and time information. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Returns the date and time the specified file or directory was last written to.
path | The file or directory for which to obtain modification date and time information. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Retrieves the names of the logical drives on this computer in the form "<drive letter>:\".
xtd::io::io_exception | An I/O error occurred (for example, a disk error). |
xtd::unauthorized_access_exception | The caller does not have the required permission. |
|
static |
Retrieves the parent directory of the specified path, including both absolute and relative paths.
path | The path for which to retrieve the parent directory. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Moves a file or a directory and its contents to a new location.
source_dir_name | The path of the file or directory to move. |
dest_dir_name | The path to the new location for source_dir_name. If source_dir_name is a file, then dest_dir_name must also be a file name. |
xtd::io::io_exception | An attempt was made to move a directory to a different volume. -or- dest_dir_name already exists. See the Note in the Remarks section. -or- The source_dir_name and dest_dir_name parameters refer to the same file or directory. -or- The directory or a file within it is being used by another process. |
xtd::argument_exception | source_dir_name or dest_dir_name is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters with the xtd::path::io::get_invalid_path_chars() method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The path specified by sourceDirName is invalid (for example, it is on an unmapped drive). |
|
static |
Deletes an empty directory from a specified path.
path | The name of the empty directory to remove. This directory must be writable and empty. |
xtd::io::io_exception | A file with the same name and location specified by path exists. -or- The directory is the application's current working directory. -or- The directory specified by path is not empty. -or- The directory is read-only or contains a read-only file. -or- The directory is being used by another process. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Deletes the specified directory and, if indicated, any subdirectories and files in the directory.
path | The name of the directory to remove. |
recursive | true to remove directories, subdirectories, and files in path; otherwise, false. |
xtd::io::io_exception | A file with the same name and location specified by path exists. -or- The directory is the application's current working directory. -or- The directory specified by path is not empty. -or- The directory is read-only or contains a read-only file. -or- The directory is being used by another process. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Sets the creation date and time for the specified file or directory.
path | The file or directory for which to set the creation date and time information. |
creation_time | The date and time the file or directory was last written to. This value is expressed in local time. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Sets the creation date and time for the specified file or directory.
path | The file or directory for which to set the creation date and time information. |
creation_time | The date and time the file or directory was last written to. This value is expressed in local time. |
xtd::io::io_exception | The directory specified by path is a file. |
xtd::argument_exception | path is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the xtd::io::path::get_invalid_path_chars method. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::io::directory_not_found_exception | The specified path is invalid (for example, it is on an unmapped drive). |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
|
static |
Sets the application's current working directory to the specified directory.
path | The path to which the current working directory is set. |
xtd::argument_exception | Attempted to set to an empty string (""). |
xtd::io::io_exception | An I/O error occurred. |
xtd::io::directory_not_found_exception | Attempted to set a local path that cannot be found. |
xtd::security::security_exception | The caller does not have the appropriate permission. |
|
static |
Sets the date and time the specified file or directory was last accessed.
path | The file or directory for which to set the access date and time information. |
last_access_time | An object that contains the value to set for the access date and time of path. This value is expressed in local time. |
xtd::argument_exception | Attempted to set to an empty string (""). |
xtd::io::io_exception | An I/O error occurred. |
xtd::io::directory_not_found_exception | Attempted to set a local path that cannot be found. |
xtd::security::security_exception | The caller does not have the appropriate permission. |
|
static |
Sets the date and time a directory was last written to.
path | The path of the directory. |
last_write_time | The date and time the directory was last written to. This value is expressed in local time. |
xtd::argument_exception | Attempted to set to an empty string (""). |
xtd::io::io_exception | An I/O error occurred. |
xtd::io::directory_not_found_exception | Attempted to set a local path that cannot be found. |
xtd::security::security_exception | The caller does not have the appropriate permission. |