private void WriteLog(string message)
{
HttpContext context = HttpContext.Current;
string filePath = Server.MapPath("~/Log/WriteLog.txt");//路径
if (!Directory.Exists(Server.MapPath("~/Log//")))
Directory.CreateDirectory(Server.MapPath("~/Log//"));
StreamWriter sr = null;
try
{
if (!File.Exists(filePath))
{
sr = File.CreateText(filePath);
}
else
{
sr = File.AppendText(filePath);
}
sr.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + message);
}
catch
{
}
finally
{
if (sr != null)
sr.Close();
}
}
{
HttpContext context = HttpContext.Current;
string filePath = Server.MapPath("~/Log/WriteLog.txt");//路径
if (!Directory.Exists(Server.MapPath("~/Log//")))
Directory.CreateDirectory(Server.MapPath("~/Log//"));
StreamWriter sr = null;
try
{
if (!File.Exists(filePath))
{
sr = File.CreateText(filePath);
}
else
{
sr = File.AppendText(filePath);
}
sr.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + message);
}
catch
{
}
finally
{
if (sr != null)
sr.Close();
}
}