I am trying to write a class that write a log based on a fairly long routing.
At various instances in the routine I need to pass the logfile name and the string I need written into a method and have it basically start a new line and add the string to the log.txt file.
this is what I have for my method
public static bool WriteLogFile(string filename, string line)
{
bool b = false;
try
{
using (StreamWriter sw = new StreamWriter(filename))
{
// Add some text to the file.
sw.WriteLine(line);
sw.Close();
}
b = true;
}
finally
{
}
return b;
}
So my problem is that this code just keeps overwriting the first line of the log file...anyone know how I can modify this code so it will create a new line and add the string their?