how to custom name of ErrorLogFile using c#
whats wrong mention code
private void LogError(Exception ex)
{
string message = string.Format("Time: {0}", dt.ToString("dd/MM/yyyy hh:mm:ss tt"));
message += Environment.NewLine;
message += "-----------------------------------------------------------";
message += Environment.NewLine;
message += string.Format("Message: {0}", ex.Message);
message += Environment.NewLine;
message += string.Format("StackTrace: {0}", ex.StackTrace);
message += Environment.NewLine;
message += string.Format("Source: {0}", ex.Source);
message += Environment.NewLine;
message += string.Format("TargetSite: {0}", ex.TargetSite.ToString());
message += Environment.NewLine;
message += "-----------------------------------------------------------";
message += Environment.NewLine;
string filename = "ErrorLog"+dt+"";
string path = Server.MapPath("~/ErrorLog/"+ filename + ".txt");
using (StreamWriter writer = new StreamWriter(path, true))
{
writer.WriteLine(message);
writer.Close();
}
}
gives error
System.NotSupportedException: 'The given path's format is not supported.'