Hi sureshMGR,
Since its a console application you can't use Server.MapPath.
For for console application you will get the path using AppDomain.CurrentDomain.BaseDirectory.
From the path get the application path and write the error log in notepad.
C#
if (Convert.ToInt32(response1.StatusCode) == 200)
{
string message = string.Format("Time: {0}", DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt"));
message += Environment.NewLine;
message += "-----------------------------------------------------------";
message += Environment.NewLine;
message += string.Format("Message: {0}", response1.StatusCode);
message += Environment.NewLine;
message += "-----------------------------------------------------------";
message += Environment.NewLine;
string path = AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "") + "\\ErrorLog";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
using (StreamWriter writer = new StreamWriter(path + "\\Success.txt", true))
{
writer.WriteLine(message);
writer.Close();
}
}