Most of the times as developers we have to work with text files, as it’s a very simple way to store some data. There are very valuable methods available in File class that we are not using most often.

Look at the following example which writes a formatted string to a text file with new lines. This is more readable than WriteLine() method. If you use WriteLine() Method then you will have to write line by line most probably you may have to use a loop.

I will show another example which writes array items in new lines.In the following example WriteAllines() method writesall the items in an array as a new line. With using WriteAllLines() method you can avoid a loop, hich needs to loop through the array and WriteLine to the text file.