File handling is an important feature in software development, when it comes to reading or writing the data to the system or From the application.
It is something helpful in the sense when we try to write something to a file Or to read some data of any type from a particular file in order to fulfill any requirement depending upon the scenario we are facing in our application.
In this article in particular, we will learn how can we write some data to a file, then reading that data from the same file and then to display the output on the console window.
so, we will consider an example of reading and writing a text file using a c# console application, In this simple example, we will just write some text data to a notepad file, following which we will be looking to read the data from the same file and then we will display it onto the console.
So, first up lets create a c# console application, we will name it as FileHandlingExample
we use the using system.IO namespace in order to perform the file handling operations in c#, so as you can see in the examples above that first we write data to a text file after which we try to read the data from the same file and display it onto the console application.
We can consider another example of reading the data from a file line by line,