This is my code. Could you please anyone tell me the reason for the error which i mentioned. Using statement usually dispose the object once it went out of scope, but i am getting the error.
public static void WriteLogFile(string message)
{
Console.WriteLine(message);
if (File.Exists("C:\\log.txt"))
{
using (StreamWriter SWriter = File.AppendText("C:\\log.txt"))
{
SWriter.WriteLine(message);
}
}
else
{
using (StreamWriter SWriter = File.CreateText("C:\\log.txt"))
{
SWriter.WriteLine(message);
}
}
}