Thursday, March 1, 2012

How to read a text file in C#

In C#, the package System.IO.File will allow you to perform various reading option from a text file.

1) reading the whole content from the file.
string fileContent = System.IO.File.ReadAllText(@"C:\input.txt");
This will read the whole content into the fileContent variable.

2) reading line by line from the text file.
string[] lines = System.IO.File.ReadAllLines(@"C:\input.txt");

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...