rachayita jaiswal

rachayita jaiswal

  • NA
  • 217
  • 106.1k

Error Log in asp.net

Aug 26 2013 3:20 AM
Hi, I am creating error log - 

public void GetErrorFile(string source, string errormessage)
    {
        string filename = "C:\\Error_" + DateTime.Now.ToString("dd-MM-yyyy") + ".txt";
        if (File.Exists(filename))
        {
            using (StreamWriter writer = new StreamWriter(filename, true))
            {
                writer.WriteLine("Time: " + DateTime.Now);
                writer.WriteLine("Source: " + source);
                writer.WriteLine("Error: " + errormessage);
                writer.WriteLine(" ");
            }
        }
        else
        {
            StreamWriter writer = File.CreateText(filename);
            writer.WriteLine("Time: " + DateTime.Now);
            writer.WriteLine("Source: " + source);
            writer.WriteLine("Error: " + errormessage);
            writer.WriteLine(" ");
            writer.Close();
        }
}

but while creating new error log i am getting error - 

Could not find a part of the path 'my path'.....
I am not getting why this error is coming?


Answers (6)