D
denislagoda
I am a beginer.
I need to read a TXT file line by line
How to do it?
I need to read a TXT file line by line
How to do it?
I am a beginer.
I need to read a TXT file line by line
How to do it?
I am a beginer.
I need to read a TXT file line by line
How to do it?
StreamReader reader = new StreamReader(filePath);//filepatj="C:/aa.txt"
while (!reader.EndOfStream)
{
InputFile = reader.ReadLine();
// do what u want
}
Som Nath Shukla said:http://msdn2.microsoft.com/en-us/library/system.io.streamreader.endofstream.aspx
use this one endofstream is property of streamreader .
use it dont worry.
StreamReader.EndOfStream - didnt find in MSDN
Som Nath Shukla said:StreamReader reader = new StreamReader(filePath);//filepatj="C:/aa.txt"
while (!reader.EndOfStream)
{
InputFile = reader.ReadLine();
// do what u want
}
this ReadLine() fuctionread the line by line and return one line at a time
as string.
Martijn said:StreamReader streamreader=new
FileInfo(filename).OpenText();
string text=streamreader.ReadLine();
while(text!=null)
{
Console.WriteLine(text);
text=streamreader.ReadLine();
}
Hilton said:...or simply (and more correctly):
using (StreamReader sr = new StreamReader (filename))
{
string line;
while ((line = sr.ReadLine()) != null)
{
do stuff
}
}
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.