public void createLog(string msg)
{
DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/OpenActiityLog.txt"));
FileInfo f = new FileInfo(Server.MapPath("~/OpenActiityLog.txt"));
int i = Convert.ToInt32(f.Length.ToString());
if (i < sw =" new" date="">" + DateTime.Now.ToString() + "- " + msg.ToString());
sw.WriteLine();
sw.WriteLine("============================================================================================");
sw.WriteLine();
sw.Flush();
sw.Close();
}
else
{
string sdate = System.DateTime.Today.ToShortDateString();
string temp = sdate.Replace('/', '-');
f.CopyTo(Server.MapPath("~/OpenActiityLog.txt") + temp + ".txt", true);
StreamWriter sw = new StreamWriter(Server.MapPath("~/OpenActiityLog.txt"), false);
sw.WriteLine("Date=>" + DateTime.Now.ToString() + "- " + msg.ToString());
sw.WriteLine();
sw.WriteLine("============================================================================================");
sw.WriteLine();
sw.Flush();
sw.Close();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment