I created a LOG file (ErrorLog) that I use to output/trace information from my application, problem is the I want to be able to read the file as things progress.
Given the way I coded it (see below) the information I write into the file is only saved afer I do the .CLOSE (meaning that if I open the .log file there is nothing written until I do the .close)
I would much rather be able to read the .log file while the application is running to see if anything is generated... (I dont want to have to CLOSE the file to see what was written to it).
Any helps/hints/clues would be appreciated - I know there is a way I just cant recall how to get it to work.
Thanks,
Given the way I coded it (see below) the information I write into the file is only saved afer I do the .CLOSE (meaning that if I open the .log file there is nothing written until I do the .close)
I would much rather be able to read the .log file while the application is running to see if anything is generated... (I dont want to have to CLOSE the file to see what was written to it).
Code:
StreamWriter ErrorLog = new StreamWriter(File.Open("App.log", FileMode.Append, FileAccess.Write, FileShare.ReadWrite));
string errMessage = DateTime.Now + ": " + sMessage;
ErrorLog.WriteLine(errMessage);
...
... do some work ...
...
ErrorLog.Close();
Any helps/hints/clues would be appreciated - I know there is a way I just cant recall how to get it to work.
Thanks,