Hi All,
I have implemented log functionality in my application which keeps track of all the user activities from the moment the application starts and till user exits the application. In My Application I create an instance of StreamWriter when the application begins and closing Stream Writer when the application exits.
My questions is when my application is running , I want to be able to go to the log file (
\\program files\\MyApplication\\log.txt") and check the log contents. When I try to pen the log file it throws an error "An error occured. The document could not be opened". How can I view the log file and see the contents when the application is running and writing to the log file?
===============================================================
StreamWriter SW; //global variable
private void StartLogger()
{
string fPath = "
\\Program Files\\My App\\log.txt;
SW = File.CreateText(fPath );
//Write in to log file
LogEntry("logfile created");
}
private void LogEntry(string entry)
{
SW.WriteLine(entry + "\n");
SW.Flush();
}
Thanks,
Ram