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

◆ name()

xtd::string xtd::io::file_info::name ( ) const
overridevirtual

Gets the name of the file.

Returns
The name of the file.
Examples
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::collections::generic;
using namespace xtd::io;
auto main() -> int {
// Create a reference to the current directory.
// Create an array representing the files in the current directory.
list<file_info> fi = di.get_files();
console::write_line("The following files exist in the current directory:");
// Print out the names of the files in the current directory.
for (file_info fi_temp : fi)
console::write_line(fi_temp.name());
}
// This code produces output similar to the following;
// results may vary based on the computer/file structure/etc.:
//
// The following files exist in the current directory:
// fileinfoname.exe
// fileinfoname.pdb
// newTemp.txt
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.h:72
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
Represents the standard input, output, and error streams for console applications.
Definition console.h:36
static xtd::string current_directory()
Gets the fully qualified path of the current working directory.
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition directory_info.h:129
xtd::string name() const override
Gets the name of the file.
Provides static methods for the creation, copying, deletion, moving, and opening of files,...
Definition file_info.h:41
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
When first called, xtd::io::file_info calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.
The name of the file includes the file extension.

Implements xtd::io::file_system_info.

Examples
file_info2.cpp.