The System.IO Namespace

File handling involves managing files. The System.IO namespace contains a number of classes and types that allow you to read and write files.

FileStream Class

The stream for a file provided by this class supports both synchronous and asynchronous read and write operations.

StreamReader

For reading characters from a stream in a certain format, the StreamReader class implements TextReader. The class includes the methods Close(), Peek(), Read(), ReadLine(), and Seek().

StreamWriter

For writing characters to a stream in a specific format, the StreamWriter class implements TextWriter. The class includes the methods Close(), Flush(), Write() and WriteLine().

BinaryReader

This class reads binary values representing primitive data types in a specific encoding.

BinaryWriter

This class supports writing strings in a specified encoding and writes primitive types in binary to a stream.

StringReader

The class StringReader implements the TextReader class, which reads strings from strings. It enables synchronous or asynchronous reading of a string. With the Read() method, you can read a character, and the ReadLine() method can read a line.

StringWriter

StringWriter is derived from TextWriter and is used to manipulate strings rather than files. StringWriter enables you to synchronously or asynchronously write to a string.

FileInfo

This class contains properties and instance methods for creating, copying, deleting, relocating, and opening files, as well as assisting in the creation of FileStream objects. This class cannot be inherited.

DirectoryInfo

This class provides instance methods for creating, moving, and enumerating through directories and subdirectories. This class is not inheritable.

2X faster app development !

Syncfusion offers over 1,800 components and frameworks for WinForms, WPF, ASP.NET (MVC, Core), UWP, WinUI, .NET MAUI, Xamarin, Flutter, Blazor, JavaScript, Angular, Vue, and React that make developers’ work easier.