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

◆ get_directories() [1/2]

std::vector< xtd::io::directory_info > xtd::io::directory_info::get_directories ( ) const

Returns the subdirectories of the current directory.

Returns
An array of xtd::io::directory_info objects.
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.
Examples
The following example retrieves all the directories in the root directory and displays the directory names.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::collections::generic;
using namespace xtd::io;
class program {
public:
static auto main() {
// Make a reference to a directory.
directory_info di("c:\\");
// Get a reference to each directory in that directory.
list<directory_info> di_arr = di.get_directories();
// Display the names of the directories.
for (directory_info dri : di_arr)
console::write_line(dri.name());
}
};
startup_(program::main);
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.h:72
Represents the standard input, output, and error streams for console applications.
Definition console.h:36
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition directory_info.h:129
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.h:175
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.h:15
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.h:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Remarks
If there are no subdirectories, this method returns an empty array. This method is not recursive.
This method pre-populates the values of the following xtd::io::directory_info properties: