I have been trying to write a program that monitors a text file, and if
the last value in the text file changes (ie : the file is updated), the
program does a series of events.
Thus far, with A LOT of forum help, I have created a program that
continiously loops through the file until the last line is found, and
will do that until the user stops the process by clicking a button.
The problem is that once the program is running, ANOTHER program might
try to access it and change the value...when I run the first program
that reads and detects a change the second program, for now a simple
..txt writer, bombs out because (I assume) the file cant be opened
twice.
Does anyone know how to get around this issue?
while (ContinueLoop == true )
{
while ((line) != null)
{
LastLine = line;
line = file.ReadLine();
}
lblCounter.Text = Counter.ToString();
lblString.Refresh();
lblCounter.Refresh();
Application.DoEvents();
Counter++;
lblString.Text = LastLine;
file.BaseStream.Seek(0,System.IO.SeekOrigin.Begin) ;
line = "not null";
} // While do until button pressed