# C# File Input and Output
A **file** is a collection of data stored on a disk with a specified name and directory path. When a file is opened for reading or writing, it becomes a **stream**.
Fundamentally, a stream is a sequence of bytes transmitted through a communication channel. There are two main types of streams: **input streams** and **output streams**. An **input stream** is used to read data from a file (read operation), and an **output stream** is used to write data to a file (write operation).
## C# I/O Classes
The System.IO namespace contains various classes for performing different file operations, such as creating and deleting files, reading or writing to files, closing files, etc.
The following table lists some commonly used non-abstract classes in the System.IO namespace:
| I/O Class | Description |
| --- | --- |
| BinaryReader | Reads primitive data from a binary stream. |
| BinaryWriter | Writes primitive data in binary format. |
| BufferedStream | Temporary storage for a byte stream. |
| Directory | Helps in manipulating directory structures. |
| DirectoryInfo | Used for performing operations on directories. |
| DriveInfo | Provides information about drives. |
| File | Helps in manipulating files. |
| FileInfo | Used for performing operations on files. |
| FileStream | Used for reading and writing to any location in a file. |
| MemoryStream | Used for random access to data stored in memory. |
| Path | Performs operations on path information. |
| StreamReader | Used for reading characters from a byte stream. |
| StreamWriter | Used for writing characters to a stream. |
| StringReader | Used for reading from a string buffer. |
| StringWriter | Used for writing to a string buffer. |
## The FileStream Class
The **FileStream** class in the System.IO namespace helps with reading, writing, and closing files. This class is derived from the abstract class Stream.
You need to create a **FileStream** object to create a new file or open an existing file. The syntax for creating a **FileStream** object is as follows:
FileStream