#include <directory_info.h>
Exposes instance 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_info. More... | |
class | file_iterator |
Represent file iterator used by xtd::io::directory_info. More... | |
class | file_system_info_iterator |
Represent file system iterator used by xtd::io::directory_info. More... | |
Fields | |
static const directory_info | empty |
Represents the uninitialized xtd::io::directory_info object. This field is constant. More... | |
Constructors | |
directory_info (const xtd::ustring &path) | |
Initializes a new instance of the xtd::io::directory_info class on the specified path. More... | |
Properrties | |
bool | exists () const override |
Gets a value indicating whether the directory exists. More... | |
xtd::ustring | name () const override |
Gets the name of this xtd::io::directory_info instance. More... | |
xtd::io::directory_info | parent () const |
Gets the parent directory of a specified subdirectory. More... | |
xtd::io::directory_info | root () const |
Gets the root portion of the directory. More... | |
Methods | |
void | create () |
Creates a directory. More... | |
xtd::io::directory_info | create_subdirectory (const xtd::ustring &path) const |
Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the xtd::io::directory_info class. More... | |
xtd::io::directory_info::directory_iterator | enumerate_directories () const |
Returns an enumerable collection of directory information in the current directory. More... | |
xtd::io::directory_info::directory_iterator | enumerate_directories (const xtd::ustring &search_pattern) const |
Returns an enumerable collection of directory information that matches a specified search pattern. More... | |
xtd::io::directory_info::file_iterator | enumerate_files () const |
Returns an enumerable collection of file information in the current directory. More... | |
xtd::io::directory_info::file_iterator | enumerate_files (const xtd::ustring &search_pattern) const |
Returns an enumerable collection of file information that matches a search pattern. More... | |
xtd::io::directory_info::file_system_info_iterator | enumerate_file_system_infos () const |
Returns an enumerable collection of file system information in the current directory. More... | |
xtd::io::directory_info::file_system_info_iterator | enumerate_file_system_infos (const xtd::ustring &search_pattern) const |
Returns an enumerable collection of file system information that matches a specified search pattern. More... | |
std::vector< xtd::io::directory_info > | get_directories () const |
Returns the subdirectories of the current directory. More... | |
std::vector< xtd::io::directory_info > | get_directories (const xtd::ustring &search_pattern) const |
Returns an array of directories in the current DirectoryInfo matching the given search criteria. More... | |
std::vector< xtd::io::file_info > | get_files () const |
Returns a file list from the current directory. More... | |
std::vector< xtd::io::file_info > | get_files (const xtd::ustring &search_pattern) const |
Returns a file list from the current directory matching the given search pattern. More... | |
std::vector< std::shared_ptr< xtd::io::file_system_info > > | get_file_system_infos () const |
Returns an array of strongly typed xtd::io::file_system_info entries representing all the files and subdirectories in a directory. More... | |
std::vector< std::shared_ptr< xtd::io::file_system_info > > | get_file_system_infos (const xtd::ustring &search_pattern) const |
Retrieves an array of strongly typed FileSystemInfo objects representing the files and subdirectories that match the specified search criteria. More... | |
void | move_to (const xtd::ustring &dest_dir_name) |
Moves a DirectoryInfo instance and its contents to a new path. More... | |
void | remove () const override |
Deletes this xtd::io::directory_info if it is empty. More... | |
void | remove (bool recursive) const |
Deletes this instance of a DirectoryInfo, specifying whether to delete subdirectories and files. More... | |
Additional Inherited Members | |
![]() | |
xtd::io::file_attributes | attributes () const |
Gets the attributes for the current file or directory. More... | |
xtd::io::file_system_info & | attributes (xtd::io::file_attributes value) |
Sets the attributes for the current file or directory. More... | |
const xtd::date_time & | creation_time () const |
Gets the creation time of the current file or directory. More... | |
xtd::io::file_system_info & | creation_time (const xtd::date_time &value) |
Gets the creation time of the current file or directory. More... | |
xtd::date_time | creation_time_utc () const |
Gets the creation time, in coordinated universal time (UTC), of the current file or directory. More... | |
xtd::io::file_system_info & | creation_time_utc (const xtd::date_time &value) |
Sets the creation time, in coordinated universal time (UTC), of the current file or directory. More... | |
virtual xtd::ustring | extension () const |
Gets the extension part of the file name, including the leading dot . even if it is the entire file name, or an empty string if no extension is present. More... | |
xtd::ustring | full_name () const |
Gets the full path of the directory or file. More... | |
const xtd::date_time & | last_access_time () const |
Gets the time the current file or directory was last accessed. More... | |
xtd::io::file_system_info & | last_access_time (const xtd::date_time &value) |
Sets the time the current file or directory was last accessed. More... | |
xtd::date_time | last_access_time_utc () const |
Gets the time, in coordinated universal time (UTC), that the current file or directory was last accessed. More... | |
xtd::io::file_system_info & | last_access_time_utc (const xtd::date_time &value) |
Sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed. More... | |
const xtd::date_time & | last_write_time () const |
Gets the time when the current file or directory was last written to. More... | |
xtd::io::file_system_info & | last_write_time (const xtd::date_time &value) |
Sets the time when the current file or directory was last written to. More... | |
xtd::date_time | last_write_time_utc () const |
Gets the time, in coordinated universal time (UTC), when the current file or directory was last written to. More... | |
xtd::io::file_system_info & | last_write_time_utc (const xtd::date_time &value) |
Sets the time, in coordinated universal time (UTC), when the current file or directory was last written to. More... | |
xtd::io::file_permissions | permissions () const |
Gets the permissions for the current file or directory. More... | |
xtd::io::file_system_info & | permissions (xtd::io::file_permissions value) |
Sets the permissions for the current file or directory. More... | |
void | refresh () |
Refreshes the state of the object. More... | |
xtd::ustring | to_string () const noexcept override |
Returns the original path. Use the xtd::io::file_system_info::full_name or xtd::io::file_system_info::name properties for the full path or file/directory name. More... | |
![]() | |
xtd::ustring | full_path_ |
Represents the fully qualified path of the directory or file. More... | |
xtd::ustring | original_path_ |
The path originally specified by the user, whether relative or absolute. More... | |
![]() | |
file_system_info ()=default | |
Initializes a new instance of the xtd::io::file_system_info class. More... | |
|
explicit |
Initializes a new instance of the xtd::io::directory_info class on the specified path.
path | A string specifying the path on which to create the xtd::io::directory_info. |
xtd::security::security_exception | The caller does not have the required permission. |
xtd::argument_exception | path contains invalid characters such as ", <, >, or |. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
void xtd::io::directory_info::create | ( | ) |
Creates a directory.
xtd::io::io_exception | The directory cannot be created. |
xtd::io::directory_info xtd::io::directory_info::create_subdirectory | ( | const xtd::ustring & | path | ) | const |
Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the xtd::io::directory_info class.
path | The specified path. This cannot be a different disk volume or Universal Naming Convention (UNC) name. |
xtd::argument_exception | path does not specify a valid file path or contains invalid xtd::io::directory_info characters. |
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::io::io_exception | The subdirectory cannot be created. -or- A file or directory already has the name specified by path. |
xtd::io::path_too_long_exception | The specified path, file name, or both exceed the system-defined maximum length. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
xtd::not_supported_exception | path contains a colon character (:) that is not part of a drive label ("C:\"). |
xtd::io::directory_info::directory_iterator xtd::io::directory_info::enumerate_directories | ( | ) | const |
Returns an enumerable collection of directory information in the current directory.
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
xtd::io::directory_info::directory_iterator xtd::io::directory_info::enumerate_directories | ( | const xtd::ustring & | search_pattern | ) | const |
Returns an enumerable collection of directory information that matches a specified search pattern.
search_pattern | The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
xtd::io::directory_info::file_system_info_iterator xtd::io::directory_info::enumerate_file_system_infos | ( | ) | const |
Returns an enumerable collection of file system information in the current directory.
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
xtd::io::directory_info::file_system_info_iterator xtd::io::directory_info::enumerate_file_system_infos | ( | const xtd::ustring & | search_pattern | ) | const |
Returns an enumerable collection of file system information that matches a specified search pattern.
search_pattern | The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
xtd::io::directory_info::file_iterator xtd::io::directory_info::enumerate_files | ( | ) | const |
Returns an enumerable collection of file information in the current directory.
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
If you only need the names of the files, use the static xtd::io::directory class for better performance. For an example, see the xtd::io::directory::enumerate_files method.
xtd::io::directory_info::file_iterator xtd::io::directory_info::enumerate_files | ( | const xtd::ustring & | search_pattern | ) | const |
Returns an enumerable collection of file information that matches a search pattern.
search_pattern | The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
|
overridevirtual |
Gets a value indicating whether the directory exists.
Implements xtd::io::file_system_info.
std::vector<xtd::io::directory_info> xtd::io::directory_info::get_directories | ( | ) | const |
Returns the subdirectories of the current directory.
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
std::vector<xtd::io::directory_info> xtd::io::directory_info::get_directories | ( | const xtd::ustring & | search_pattern | ) | const |
Returns an array of directories in the current DirectoryInfo matching the given search criteria.
search_pattern | The search string to match against the names of directories. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
std::vector<std::shared_ptr<xtd::io::file_system_info> > xtd::io::directory_info::get_file_system_infos | ( | ) | const |
Returns an array of strongly typed xtd::io::file_system_info entries representing all the files and subdirectories in a directory.
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
std::vector<std::shared_ptr<xtd::io::file_system_info> > xtd::io::directory_info::get_file_system_infos | ( | const xtd::ustring & | search_pattern | ) | const |
Retrieves an array of strongly typed FileSystemInfo objects representing the files and subdirectories that match the specified search criteria.
search_pattern | The search string to match against the names of directories and files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
std::vector<xtd::io::file_info> xtd::io::directory_info::get_files | ( | ) | const |
Returns a file list from the current directory.
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
std::vector<xtd::io::file_info> xtd::io::directory_info::get_files | ( | const xtd::ustring & | search_pattern | ) | const |
Returns a file list from the current directory matching the given search pattern.
search_pattern | The search string to match against the names of files. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions. |
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
Wildcard specifier | Matches |
---|---|
* (asterisk) | Zero or more characters in that position. |
? (question mark) | Zero or one character in that position. |
void xtd::io::directory_info::move_to | ( | const xtd::ustring & | dest_dir_name | ) |
Moves a DirectoryInfo instance and its contents to a new path.
dest_dir_name | The name and path to which to move this directory. The destination cannot be another disk volume or a directory with the identical name. It can be an existing directory to which you want to add this directory as a subdirectory. |
xtd::io::directory_not_found_exception | The specified path is invalid, such as being on an unmapped drive. |
xtd::io::io_exception | The directory is not empty. -or- The directory is the application's current working directory. -or- There is an open handle on the directory. |
xtd::security::security_exception | The caller does not have code access permission to create the directory. |
|
overridevirtual |
Gets the name of this xtd::io::directory_info instance.
Implements xtd::io::file_system_info.
xtd::io::directory_info xtd::io::directory_info::parent | ( | ) | const |
Gets the parent directory of a specified subdirectory.
xtd::security::security_exception | The caller does not have the required permission. |
|
overridevirtual |
Deletes this xtd::io::directory_info if it is empty.
xtd::unauthorized_access_exception | The directory contains a read-only file. |
xtd::io::directory_not_found_exception | The directory described by this xtd::io::directory_info object does not exist or could not be found. |
xtd::io::io_exception | The directory is not empty. -or- The directory is the application's current working directory. -or- There is an open handle on the directory. |
xtd::security::security_exception | The caller does not have the required permission. |
Implements xtd::io::file_system_info.
void xtd::io::directory_info::remove | ( | bool | recursive | ) | const |
Deletes this instance of a DirectoryInfo, specifying whether to delete subdirectories and files.
recursive | true to delete this directory, its subdirectories, and all files; otherwise, false. |
xtd::unauthorized_access_exception | The directory contains a read-only file. |
xtd::io::directory_not_found_exception | The directory described by this xtd::io::directory_info object does not exist or could not be found. |
xtd::io::io_exception | The directory is not empty. -or- The directory is the application's current working directory. -or- There is an open handle on the directory. |
xtd::security::security_exception | The caller does not have the required permission. |
xtd::io::directory_info xtd::io::directory_info::root | ( | ) | const |
Gets the root portion of the directory.
xtd::security::security_exception | The caller does not have the required permission. |
|
static |
Represents the uninitialized xtd::io::directory_info object. This field is constant.