File I/O
File is nothing but a collection of data that stores physically in a directory of the system. The data that file contains could be any information. In C#, whenever the file is available programmatically for information retrieval (read) or updating information (write), that is nothing but a stream.
Note
Stream is nothing but a sequence of bytes.
In the C# file, I/O is just a way to call input streams or output streams:
- Input stream: This is nothing but a read operation. Whenever we programmatically read the data from the file, it is called an input stream or a read operation.
- Output stream: This is nothing but an update operation. Whenever we programmatically add data to the file, it is called an output stream or a write operation.
File I/O is a part of the System.IO
namespace that contains various classes. In this section, we will discuss FileStream that we will use in our code example.
Note
A complete list of System.IO classes is available at https://docs.microsoft.com/en-us/dotnet/api...