How to read, write, append in text file using C#

preview_player
Показать описание
How to read, write, append in text file using C#:

Working steps to show how to read, write, append in text file using C#:

1. Taken a new form, design it with heading Label, 3 button – changed some font and color properties to look better.
2. At first I have declared a variable named thepath to define a specific path location where I want to create text file and read, write, append content
3. To write content in text file I have used WriteAllText method before doing that I have checked is any file exist in this location by this name , if not then it take the content from the string variable and create the text file.
4. Here I have shown a message to show that file create.
5. To add more content in text file I have used AppendAllText method that takes content from the string variable and append or add text to the text file.
6. To read content from text file I have used ReadAllText method that retrieve content from the text file all at once and I have showed it by a message.
7. We can read content from text file line by line using another method called ReadAllLines and set it to a string type array and then retrieve all lines using a for each loop. Here I have passed the variable to message that showed the content line by line.
8. Run and check

To find the code I have written in this video, join to our facebook group by clicking following link:

You can also like to our facebook Page to get all video code clicking on following link:


You can follow us on twitter clicking on following link:

We will create thousands of video related with information technology from our practical experience and those are used in our daily work and development. Stay with us.

Do like, share and comments and subscribe to my channel and click on bell button to get notification when new video uploaded. You may suggest me to make new video with new topic.

Here is the channel subscription link:

Thanks again
Рекомендации по теме
welcome to shbcf.ru