📄 tools.cs
字号:
using System;
using System.IO;
using System.Web;
using System.Net.Mail;
public class Tools
{
public static void Log(string Message)
{
Tools.Log(Message, null);
}
public static void Log(string Message, Exception Ex)
{
string fileName = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "WroxUnited.log");
using (StreamWriter logFile = new StreamWriter(fileName, true))
{
logFile.WriteLine("{0}: {1}", DateTime.Now, Message);
if (Ex != null)
logFile.WriteLine(Ex.ToString());
logFile.Close();
}
}
public static void SendMail(string Message)
{
Tools.SendMail(Message, null);
}
public static void SendMail(string Message, Exception Ex)
{
using (MailMessage msg = new MailMessage("website@wroxunited.net", "admin@wroxunited.net"))
{
msg.Subject = "WroxUnited.net Web Site Error";
if (Ex == null)
msg.Body = "There was an error on the website";
else
msg.Body = Ex.ToString();
SmtpClient client = new SmtpClient("MyMailServer");
client.UseDefaultCredentials = true;
client.Send(msg);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -