Skip to main content

Common I/O Tasks

The xtd::io namespace provides several classes that allow for various actions, such as reading and writing, to be performed on files, directories, and streams. For more information, see File and Stream I/O.


Prefer in your application to use the Input/output library and Filesystem library of the std.

xtd has its own IO API because the Filesystem library doesn't work on all OS (like for example iOS).

Some features exist only in the xtd API like binary reader/writer, stream reader/writer, string reader/writer and text reader/writer.

Common File Tasks

To do this... See the example in this topic...
Create a text filextd::io::file::create_text method
xtd::io::file_info::create_text method
xtd::io::file::create method
xtd::io::file_info::create method
Write to a text fileHow to: Write Text to a File
How to: Write a Text File
Read from a text fileHow to: Read Text from a File
Append text to a fileHow to: Open and Append to a Log File
xtd::io::file::append_text method
xtd::io::file_info.append_text method
Rename or move a filextd::io::file::move method
xtd::io::file_info::move_to method
 Delete a filextd::io::file::remove method
xtd::io::file_info::remove method
Copy a filextd::io::file::copy method
xtd::io::file_info::copy_to method
 Get the size of a filextd::io::file_info::length property
Get the attributes of a filextd::io::file::get_attributes method
Set the attributes of a filextd::io::file::set_attributes method
Determine whether a file existsxtd::io::file::exists method
Read from a binary fileHow to: Read and Write to a Newly Created Data File
 Write to a binary fileHow to: Read and Write to a Newly Created Data File
Retrieve a file name extensionxtd::io::path::get_extension method
Retrieve the fully qualified path of a filextd::io::path::get_full_path method
Retrieve the file name and extension from a pathxtd::io::path::get_file_name method
Change the extension of a filextd::io::path::change_extension method

Common Directory Tasks

To do this... See the example in this topic...
Access a file in a special folder such as My DocumentsHow to: Write Text to a File
Create a directoryxtd::io::directory::create_directory method
xtd::io::file_info::directory property
Create a subdirectoryxtd::io::directory_info.create_subdirectory method
Rename or move a directoryxtd::io::directory::move method
xtd::io::directory_info::move_to method
Copy a directoryHow to: Copy Directories
Delete a directoryxtd::io::directory::remove method
xtd::io::directory_info::remove method
See the files and subdirectories in a directoryHow to: Enumerate Directories and Files
Find the size of a directoryxtd::io::directory_info::length class
Determine whether a directory existsxtd::io::directory::exists method

See also