xtd 0.2.0
Loading...
Searching...
No Matches

◆ enumerate_directories() [2/2]

xtd::io::directory_info::directory_iterator xtd::io::directory_info::enumerate_directories ( const xtd::string search_pattern) const

Returns an enumerable collection of directory information that matches a specified search pattern.

Parameters
search_patternThe 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.
Returns
An xtd::io::directory_info::directory_iterator of directories that matches search_pattern.
Exceptions
xtd::io::directory_not_found_exceptionThe specified path is invalid, such as being on an unmapped drive.
xtd::security::security_exceptionThe caller does not have code access permission to create the directory.
Remarks
searchPattern can be a combination of literal and wildcard characters, but it doesn't support regular expressions. The following wildcard specifiers are permitted in searchPattern.
Wildcard specifier Matches
* (asterisk) Zero or more characters in that position.
? (question mark) Zero or one character in that position.
Characters other than the wildcard are literal characters. For example, the string "*t" searches for all names in ending with the letter "t". ". The searchPattern string "s*" searches for all names in path beginning with the letter "s".
The xtd::io::directory_info::enumerate_directories and xtd::io::directory_info::get_directories methods differ as follows:
* When you use xtd::io::directory_info::enumerate_directories, you can start enumerating the collection of xtd::io::directory_info objects before the whole collection is returned.
* When you use xtd::io::directory_info::get_directories, you must wait for the whole array of xtd::io::directory_info objects to be returned before you can access the array.
Therefore, when you are working with many files and directories, xtd::io::directory_info::enumerate_directories can be more efficient.
This method pre-populates the values of the following xtd::io::directory_info properties: