代码段——写日志文件
/// <summary>
/// 写入日志
/// </summary>
public void WriteLog(string message)
{
string path = AppDomain.CurrentDomain.BaseDirectory + "/MyLog.txt";
using (StreamWriter sw = new StreamWriter(path, true, Encoding.Default))
{
sw.Flush();
sw.WriteLine("时间:" + DateTime.Now);
sw.WriteLine("内容:" + message);
sw.WriteLine("-------------------------");
}
}