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

◆ root()

xtd::io::directory_info xtd::io::directory_info::root ( ) const

Gets the root portion of the directory.

Returns
An object that represents the root of the directory.
Exceptions
xtd::security::security_exceptionThe caller does not have the required permission.
Examples
The following example displays root locations for specified directories.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::io;
class program {
public:
static auto main() {
directory_info di1(R"(\\tempshare\tempdir)");
directory_info di2("tempdir");
directory_info di3(R"(x:\tempdir)");
directory_info di4(R"(c:\)");
console::write_line("The root path of '{0}' is '{1}'", di1.full_name(), di1.root());
console::write_line("The root path of '{0}' is '{1}'", di2.full_name(), di2.root());
console::write_line("The root path of '{0}' is '{1}'", di3.full_name(), di3.root());
console::write_line("The root path of '{0}' is '{1}'", di4.full_name(), di4.root());
}
};
startup_(program::main);
/*
This code produces output similar to the following:
The root path of '\\tempshare\tempdir' is '\\tempshare\tempdir'
The root path of 'c:\Projects\ConsoleApplication1\ConsoleApplication1\bin\Debug\tempdir' is 'c:\'
The root path of 'x:\tempdir' is 'x:\'
The root path of 'c:\' is 'c:\'
*&zwj;/
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::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