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

◆ attributes() [1/2]

xtd::io::file_attributes xtd::io::file_system_info::attributes ( ) const

Gets the attributes for the current file or directory.

Returns
xtd::io::file_attributes of the current xtd::io::file_system_info.
Exceptions
xtd::io::file_not_found_exceptionThe specified file doesn't exist. Only thrown when setting the property value.
xtd::io::directory_not_found_exceptionThe specified path is invalid. For example, it's on an unmapped drive. Only thrown when setting the property value.
xtd::io::path_too_long_exceptionThe specified path, file name, or both exceed the system-defined maximum length.
xtd::argument_exceptionThe specified path, file name, or both exceed the system-defined maximum length.
xtd::io::io_exceptionxtd::io::file_system_info::refresh() cannot initialize the data.
Remarks
The value of the xtd::io::file_system_info::attributes property is pre-cached if the current instance of the xtd::io::file_system_info object was returned from any of the following xtd::io::directory_info methods:
The value may be cached when either the value itself or other xtd::io::file_system_info properties are accessed. To get the latest value, call the xtd::io::file_system_info::refresh method.
If the path doesn't exist as of the last cached state, the return value is static_cast<xtd::io::file_attributes>(-1). xtd::io::file_not_found_exception or xtd::io::directory_not_found_exception can only be thrown when setting the value.
The value of this property is a combination of the archive, compressed, directory, hidden, offline, read-only, system, and temporary file attribute flags.
When you set this value, use the bitwise OR operator (|) to apply more than one value. To retain any existing values in the xtd::io::file_system_info::attributes property, include the value of the xtd::io::file_system_info::attributes property in your assignment. For example:
example_file.attributes(example_file.attributes() | file_attributes::read_only; 
Examples
The following example demonstrates the xtd::io::file_system_info::attribute property. This code example is part of a larger example provided for the xtd::io::file_system_info class.
static void display_file_system_info_attributes(const file_system_info& fsi) {
// Assume that this entry is a file.
string entry_type = "File";
// Determine if entry is really a directory
entry_type = "Directory";
}
// Show this entry's type, name, and creation date.
console::write_line("{0} entry {1} was created on {2:D}", entry_type, fsi.full_name(), fsi.creation_time());
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
const xtd::date_time & creation_time() const
Gets the creation time of the current file or directory.
xtd::io::file_attributes attributes() const
Gets the attributes for the current file or directory.
xtd::string full_name() const
Gets the full path of the directory or file.
Provides the base class for both xtd::io::file_info and xtd::io::directory_info objects.
Definition file_system_info.h:87
@ directory
The file is a directory.
Examples
file_info2.cpp.