How to read first and last line of my text file.

Posted by Anishabathija under ASP.NET on 12/11/2012 | Points: 10 | Views : 1102 | Status : [Member] | Replies : 1
hey could you please help me with a code that reads my first and last line of the file.


Posted by: Sandhyab on: 12/11/2012 [Member] Starter | Points: 25

string line;
// Read and display lines from the file until the end of
// the file is reached.
StreamReader sr = new StreamReader(path);//path is your file path
while ((line = sr.ReadLine()) != null)
//Write your code here
//And you can check
ReadToEnd() function, to read it all in at once.

Thanks & Regards

Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response