Connecting Tech Pros Worldwide Forums | Help | Site Map

Reading end of file stream in C# problem

Newbie
 
Join Date: Sep 2006
Posts: 1
#1: Sep 10 '06
Hey all,

I'm trying to make my app read the stream of a text file and begin at the end of the file. Then parse all the lines that get added in the text file by a other app (Its a log file from a game) and display it in a multiple editbox or richeditbox.

Ive tryed somthing like this


private FileStream file;
private StreamReader stream;

public void logInstance()
{
file = new FileStream("f:\\everquest\\logs\\eqlog_Machia_xego ny.txt",
FileMode.Open, FileAccess.Read);

stream = new StreamReader(file);
stream.BaseStream.Seek(0, SeekOrigin.End);
}

// This is a timer and schould display all new added lines of text to the richeditbox

public void timer_Tick(object sender, EventArgs e)
{
string logString = stream.ReadLine();

if (logString != null)
{
richTextBox.Text += logString + " \n";
}
}

Anyone has a idee how to do this? the above code will display nothing, if i change the seek to begin it will parse the text file trough.

Reply