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

◆ extension()

virtual xtd::string xtd::io::file_system_info::extension ( ) const
virtual

Gets the extension part of the file name, including the leading dot . even if it is the entire file name, or an empty string if no extension is present.

Returns
A string containing the xtd::io::file_system_info extension.
Remarks
The Extension property returns the FileSystemInfo extension, which starts at, and includes, the last dot (.) in the file's full name. For example:
  • For a file c:\NewFile.txt, this property returns ".txt".
  • For a file c:.gitignore, this property returns ".gitignore".
  • For a file c:\noextension, this property returns an empty string "".
  • For a file c:.b.c, this property returns ".c".
  • When the xtd::io::file_system_info is constructed from a file path with a trailing dot, then that trailing dot is trimmed, so new xtd::io::file_system_info("foo.bar.").extension returns ".bar".
The following table lists examples of other typical or related I/O tasks.
To do this... See the example in this topic...
 Create a text file. How to: Write Text to a File
 Write to a text file. How to: Write Text to a File
 Read from a text file. How to: Read Text to a File
Retrieve the fully qualified path of a file. xtd::io::path::get_full_path
Retrieve only the file name a path. xtd::io::path::get_file_name_without_extension
Retrieve only the directory name from a path. xtd::io::path::get_directory_name
 Change the extension of a file. xtd::io::path::change_extrnsion
Examples
file_info2.cpp.