Hi
I use below code in global.asax for my error page that when some error happen in my website it go to error.aspx page and save text of error in log.txt file
void Application_Error(object sender, EventArgs e)
{
string filename = Server.MapPath(".") + "\\log.txt";
if (!System.IO.File.Exists(filename))
System.IO.File.Create(filename);
System.IO.StreamWriter sw = new System.IO.StreamWriter(filename, true);
sw.Write(DateTime.Now + "\n\r" + Server.GetLastError() + "\n\r\n\r");
sw.Close();
Response.Redirect("error.aspx");
}
here during the day maybe there will be many error in my website so log.txt file grows very fast I want if i.e size of log.txt file be morethan 30MB it clear this file text Automaticly
How I can do it?
best regards
Neda